-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.py
60 lines (41 loc) · 1.2 KB
/
convert.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
#!/bin/python3
# Created by Jacobus Burger (2022)
# Info:
# I wanted to build a program that converts between metric and imperial
# measures of weight.
# It's not very smart, and there's definitely room for improvement, but it
# is a learning experience and a chance to do something, not matter how
# small it is.
# Inspired by google's magic search engine converters
import re
from sys import argv
def c(k):
"""Convert from Kelvin to Celcius"""
return k - 273.15
def c(f):
"""Convert from Farenheit to Celcius"""
return (f - 32) * (5/9)
def f(c):
"""Convert from Celcius to Farenheit"""
return c * (5/9) + 32
def f(k):
"""Convert from Kelvin to Farenheit"""
return (k - 273.15) * (9/5) + 32
def k(f):
"""Convert from Farenheit to Kelvin"""
return (f - 32) * (5/9) + 273.15
def k(c):
"""Convert from Celcius to Kelvin"""
return c + 273.15
def kg(lb):
"""Convert from pounds to kilograms"""
return lb * 0.45359237
def lb(kg):
"""Convert from kilograms to pounds"""
return kg * 2.20462
def m(in):
"""Convert from inches to meters"""
return in * 0.0254
def in(m):
"""Convert from meters to inches"""
return m * 39.3701