feat: Initial commit
This commit is contained in:
45
Laboratorio3/convert.py
Normal file
45
Laboratorio3/convert.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from sys import exit
|
||||
|
||||
fr = input("Convert from? ")
|
||||
to = input("Convert to? ")
|
||||
|
||||
factor = 0
|
||||
|
||||
if fr == "ml" or fr == "l":
|
||||
if to == "fl. oz":
|
||||
factor = 0.033814
|
||||
elif to == "gal":
|
||||
factor = 0.000264172
|
||||
|
||||
if fr == "l":
|
||||
factor *= 1000
|
||||
|
||||
if fr == "g" or fr == "kg":
|
||||
if to == "oz":
|
||||
factor = 0.035274
|
||||
elif to == "lb":
|
||||
factor = 0.00220462
|
||||
|
||||
if fr == "kg":
|
||||
factor *= 1000
|
||||
|
||||
if fr == "mm" or fr == "cm" or fr == "m" or fr == "km":
|
||||
if to == "ft":
|
||||
factor = 0.00328084
|
||||
elif to == "mi":
|
||||
factor = 6.21371 * 10**(-7)
|
||||
|
||||
if fr == "cm":
|
||||
factor *= 10
|
||||
elif fr == "m":
|
||||
factor *= 1000
|
||||
elif fr == "km":
|
||||
factor *= 1000000
|
||||
|
||||
if factor == 0:
|
||||
exit("Impossible conversion")
|
||||
|
||||
val1 = float(input("Value? "))
|
||||
val2 = val1 * factor
|
||||
|
||||
print(val1, " ", fr, " = ", val2, " ", to)
|
||||
Reference in New Issue
Block a user