More advanced Python

So Python is pretty simple. I’m just doing some basic float based calculations. A converter app of sorts.

See if you can figure out what it does and how.

def cvttemp(): #Temperature Conversion
print (“Enter temperature in Fahrenheit:/n”)
t= float(input (“Temp in F:”))
print (“Temp in C is: “)
print ((t-32)*(5/9)) # Standard F to C calculation in print statement
return()
def cvtctof: #Celsius to Fahrenheit
c= float(input(“Temp in C:”))
print(c)

def cvtdist(): #KM to Miles
print (“Enter distance in km”)
d=float(input(“Distance in KM:”))
print(((d/2)*.25)+d/2)
return()

def cvtliquid(): $Liters to Ounces
print(“Enter volume in liters”)
v=input(“Volume in Liters:”)
print(v)
return()

print (“Prees 1 for F to C”)
print (“Press 2 for C to F”)
print (“Press 3 for KM to Miles”)
print (“Press 4 for Miles to KM”)
print (“Press 5 for Liters to Ounces”)
print (“Press 6 for Ounce to Liters”)

a = int(input (“Enter your choice now: “))

if a == 1:
cvttemp()
elif a==2:
cvtctof()
elif a==3:
cvtdist()
elif a==4:
#Fill in Miles to KM calc – define the function.
elif a==5:
cvtliquid()

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.