-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconversions.py
61 lines (51 loc) · 1.92 KB
/
conversions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#Jonathan Harris
#August 5, 2014
#Conversion Library
#Build #: Alpha 1.0.0.0
""" This is the basis unit conversion library made in python for my unit
conversion program. The basis behind this is to get used to making programs in
python as well as making GUI."""
#Temperature Class
class Temperature:
"""The Conversion from Celsius to Fahrenheit"""
def C2F(self,Celsius):
self.Celsius = Celsius
self.Fahrenheit = (self.Celsius*9)/5 + 32
return round(self.Fahrenheit, 3)
"""The Conversion from Fahrenheit to Celsius"""
def F2C(self, Fahrenheit):
self.Fahrenheit = Fahrenheit
self.Celsius = ((self.Fahrenheit-32)*5)/9
return round(self.Celsius, 3)
"""The Conversion from Kelvin to Celsius"""
def K2C(self, Kelvin):
self.Kelvin = Kelvin
self.Celsius = self.Kelvin - 273.15
return round(self.Celsius, 3)
"""The Conversion from Celsius to Kelvin"""
def C2K(self, Celsius):
self.Celsius = Celsius
self.Kelvin = self.Celsius + 273.15
return round(self.Kelvin, 3)
"""The Conversion from Kelvin to Fahrenheit"""
def K2F(self, Kelvin):
self.Kelvin = Kelvin
self.Fahrenheit = 1.8*(self.Kelvin-273)+32
return round(self.Fahrenheit, 3)
"""The Conversion from Fahrenheit to Kelvin"""
def F2K(self, Fahrenheit):
self.Fahrenheit = Fahrenheit
self.Celsius = ((self.Fahrenheit-32)*5)/9
self.Kelvin = self.Celsius + 273.15
return round(self.Kelvin, 3)
class Length:
"""The Conversion from feet to meters"""
def F2M(self, Feet):
self.Feet = Feet
self.Meters = (self.Feet * 0.304)
return round(self.Meters, 4)
"""The Conversion from meters to feet"""
def M2F(self, Meters):
self.Meters = Meters
self.Feet = (self.Meters * 3.2804)
return round(self.Feet, 4)