Volume Calculator

Learning Objectives

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).

Challenge #1:


Complete the following code to add 3 functions as follows:

  • getVolumeOfCylinder(radius, height)
  • getVolumeOfCuboid(width, length, height)
  • getVolumeOfCone(radius, height)

Challenge #2:


Use all of your functions to calculate the volume of each of these bottles:
BottlesABCD

Share Button
Posted in Computer Science, Python - Intermediate, Python Challenges

Our Latest Book