Posts

Showing posts from March, 2024

Imperial to Metric Conversion (and vice-versa) Script

Image
 Imperial to Metric Conversion (and vice-versa) Script An idea for a project that I had was one to have a python script that would use functions to convert Imperial values to Metric and also Metric values to Imperial. This is useful here in Canada, where we will often measure temperature in Celcius and distance in kilometers, but then also measure height in feet and weight in pounds! It can all get a bit much to keep track of sometimes. I wanted to get more familiar with classes in python, so I started with a master 'Conversion' class that would handle the math, and then several local classes for each kind of unit being converted. This is the main class and the units being utilized: class Converter:     """     A class to convert values between different units of measurement.     Supports temperature, length, volume, and weight conversions.     """     def __init__(self):         """         Initializes the Converter class with dicti