My Conversion Library

conversion

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-miles-to-km-1
conversion-inches-to-cm-1
conversion-temperatureConverting Temperatures

conversion-celsius-to-fahrenheit-1
conversion-weightConverting Weights

conversion-kg-to-lb-1
conversion-timeTime Conversion

conversion-seconds-1

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

Our Latest Book