Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By : Dan Nixon
Book Image

Getting Started with Python and Raspberry Pi (Redirected from Learning Python By Developing Raspberry Pi Applications)

By: Dan Nixon

Overview of this book

Table of Contents (18 chapters)
Getting Started with Python and Raspberry Pi
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Unit conversion application


Before we can design the command line interface, we need to build up the framework for the unit conversion application. A rough structure of this application is shown in the following UML diagram:

Note

Note that because the unit conversion portion of this application is not the main focus here, not all the code for the unit conversions will be listed. However, they are available with the code download for this chapter.

The UnitTable class contains functions that convert between the units by first converting to a common base unit. To do this, there are two dictionaries with conversion steps for each unit supported by the table: one to convert to from the base unit and one to convert to the base unit.

Additional tables are created by inheriting from the UnitTable class and adding new entries to the to_base_unit and from_base_unit dictionaries. Note that every unit in a unit table must be able to convert to and from the base unit.

We will start by using the existing unit...