My Conversion Library


Learning Objectives

In this challenge you will learn how to create your own library and how to use it in your programs.

A library is a collection of functions and procedures. A library can then be reused in all your programs using the import instruction.

You have most likely used some libraries in the past, for instance the random library or the maths library.

We are going to create our own library focusing on conversion formulas. It will be useful when we need to convert for example distances from one unit to another (e.g. miles to km, cm to inches).

We have started the library for you by defining two functions: kmToMiles() and milesToKm().

Your Challenge

Complete the library to add the following conversion functions (Roll-over the frames below to reveal the conversion formula):

conversion-distanceConverting Distances

conversion-temperatureConverting Temperatures

conversion-weightConverting Weights

conversion-timeTime Conversion


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

Our Latest Book