Write a function to calculate volume of a box with appropriate default values for its parameters. Your function should have the following input parameters:
- Length of box
- Width of box
- Height of box
Test it by writing a 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
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
)
Output
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