By completing this challenge we are going to learn how to define our own functions in Python.
We will also assign arguments to our functions.
Look at the code below used to calculate the volume of a cube. This code is based on the use of a function called getVolumeOfCube(). This function takes one argument (width) and return the volume of the cube (in mL).
volume = width * width * width
#This calculates the volume in cubic millimeters. Divide it by 1000 to get this volume in mL
#Main Program Starts Here
print("The volume of a cube with a side of 50mm is: " + str(cubeVolume) + " mL.")
Complete the following code to add 3 functions as follows:
- getVolumeOfCylinder(radius, height)
- getVolumeOfCuboid(width, length, height)
- getVolumeOfCone(radius, height)
Use all of your functions to calculate the volume of each of these bottles: