CBSE Class 12 Computer Science
Question 96 of 103
Working with Functions — Question 2
Back to all questions 2
Question Write a function to calculate volume of a box with appropriate default values for its parameters. Your function should have the following input parameters :
(a) length of box ;
(b) width of box ;
(c) height of box.
Test it by writing complete program to invoke it.
def calculate_volume(length = 5, width = 3, height = 2):
return length * width * height
default_volume = calculate_volume()
print("Volume of the box with default values:", default_volume)
v = calculate_volume(10, 7, 15)
print("Volume of the box with default values:", v)
a = calculate_volume(length = 23, height = 6)
print("Volume of the box with default values:", a)
b = calculate_volume(width = 19)
print("Volume of the box with default values:", b)Volume of the box with default values: 30
Volume of the box with default values: 1050
Volume of the box with default values: 414
Volume of the box with default values: 190