Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider making a function (mini program to complete a specific task) for each o

ID: 3738777 • Letter: C

Question

Consider making a function (mini program to complete a specific task) for each of the scenarios below. State what the purpose of the function is in your own words, specify input that is needed by the function, what output is expected from the functions, and the step by step process that will obtain the output from the input (the algorithm). In addition to these 4 items also specify test data that can be used for each problem. Remember to describe your steps in enough detail so someone other than you could follow your algorithm and solve the problem. Also do not write any actual code. However as you list the steps, you may want to employ statements such as “repeat steps 2-4 until n is reached.

Problem 1: Create a process to calculate the volume of a cylinder and return the volume.

Problem 2: Create a process that would sum up all the values in a column of a 2-dimensional array or list (do not use any python functions).

Program 3: Create a process that would find the average of a 2-dimensional of all the values in a 2-dimensional array or list (do not any python functions).

Explanation / Answer

Problem 1: Create a process to calculate the volume of a cylinder and return the volume.

Solution 1:

                Purpose: Calculating the volume of a cylinder and returning it.

                Input: i) Radius of Cylinder, ii) Height of Cylinder

                Output: Volume of cylinder

                Pseudo Code:

                                //Function to calculate volume

                                Return_Vol Function_Cylinder_Vol(input_radius, input_Height)

                                {

                                                //formula to calculate Volume of cylinder

                                                Vol = pi* input_radius* input_radius* input_Height

                                                //return Volume

                                                Return Vol

}

                Example: Input_radius = 2, Input_height = 7, then Output_Vol = 88

Problem 2: Create a process that would sum up all the values in a column of a 2-dimensional array or list (do not use any python functions).

Solution 2:

                Purpose: calculate the sum of all the values in a column of a 2-dimensional array

                Input: i) 2-D array, ii) Column_Number

                Output: Sum of all the values in a column of 2-D array

                Pseudo Code:

                                Return_Sum Function_Calculate_Sum(Input_array, Input_Column)

                                {

Temp_no = 0, Sum = 0
Increment Temp_no
Sum = Sum + Input_array[Temp_no][ Input_Column]
Repeat 2 to 4 untill last row
Return Sum

}

                Example: Input_array = {{1,2},{3,4}}, Input_Column = 1, Output_Sum =4

Program 3: Create a process that would find the average of a 2-dimensional of all the values in a 2-dimensional array or list (do not any python functions).

Solution 2:

                Purpose: calculate the sum of all the values of a 2-dimensional array

                Input: 2-D array

                Output: Sum of all the values of 2-D array

                Pseudo Code:

                                Return_Sum Function_Calculate_Sum(Input_array)

                                {

Row_No = 0 Sum = 0
Col_No = 0
Increment Row_No
Increment Col_No
Sum = Sum + Input_array[Row_No][ Col_No]
Repeat 4 and 6 untill last column
Repeat 2 to 7 untill last Row
Return Sum

}

                Example: Input_array = {{1,2},{3,4}}, Output_Sum = 10

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote