120k views
2 votes
In this module you learned about advanced modularization techniques. You learned about the advantages of modularization and how proper modularization techniques can increase code organization and reuse.

Create the PYTHON program allowing the user to enter a value for one edge of a cube(A box-shaped solid object that has six identical square faces).
Prompt the user for the value. The value should be passed to the 1st and 3rd functions as arguments only.
There should be a function created for each calculation
One function should calculate the surface area of one side of the cube. The value calculated is returned to the calling statement and printed.
One function should calculate the surface area of the whole cube(You will pass the value returned from the previous function to this function) and the calculated value results printed.
One function should calculate the volume of the cube and print the results.
Make a working version of this program in PYTHON.

User Dionna
by
5.6k points

1 Answer

4 votes

Answer:

Following are the code to the given question:

def getSAOneSide(edge):#defining a method that getSAOneSide that takes edge patameter

return edge * edge#use return to calculate the edge value

def getSA(SA_one_side):#defining a method that getSA that takes SA_one_side patameter

return 6 * SA_one_side#use return to calculate the SA_one_side value

def volume(edge):#defining a method that volume that takes edge patameter

return edge * edge * edge#use return to calculate edge value

edge = int(input("Enter the length of edge of the cube:\\"))#defining edge variable that input value

SA_one_side = getSAOneSide(edge)#defining SA_one_side that holds getSAOneSide method value

print("Surface area of one side of the cube:", SA_one_side)

surfaceArea = getSA(SA_one_side)#defining a surfaceArea that holds getSA method value

print("Surface area of the cube:", surfaceArea)#print surfaceArea value

vol = volume(edge)#defining vol variable that holds Volume method value

print("Volume of the cube:", vol)#print vol Value

Output:

Please find the attached file.

Step-by-step explanation:

In the code three method "getSAOneSide, getSA, and volume" method is declared that takes a variable in its parameters and use a return keyword that calculates and return its value.

In the next step,edge variable is declared that holds value from the user and defines three variable that holds method value and print its value with the message.

In this module you learned about advanced modularization techniques. You learned about-example-1
User Derit Agustin
by
5.7k points