Write a python program that finds the cubic volume of a rectangle. Ask the user
ID: 3855088 • Letter: W
Question
Write a python program that finds the cubic volume of a rectangle. Ask the user to enter the length, width and height, in feet, of a rectangle. Your program should use the formula L x W x H to compute and display the cubic feet of the rectangle. L will represent the length, W will represent the width and H will represent the height. Your program should include an input function, a processing function and an output function in addition to your main function. Do not forget to include the unit of measurement you are using in the output function. Provide meaningful comments in your code to let other coders know what your intentions are for each function.
Explanation / Answer
Code:
def inputFunction():
l = int(raw_input("Enter the length in inches: "))
b = int(raw_input("Enter the breadth in inches: "))
h = int(raw_input("Enter the height in inches: "))
return l, b, h
def calculateVolume(l,b,h):
return l*b*h
def outputFunction(n):
print("The volume of the cube is %d sq.inches "%n)
def main():
l,b,h = inputFunction()
n = calculateVolume(l,b,h)
outputFunction(n)
main()
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.