Code
def welcome():
print ("Welcome to the Metric Conversion Program\nThis program will take a unit of measurement and convert\nit to degrees Celcius or Meters.\n**********************************************************")
def choices():
choice = str(input("Here are your choices:\n\tC for Celcius\n\tM for Meters\n\tE for Exit\n\n")).upper()
Fahrenheit = 0.0
Celcius = 0.0
Feet = 0.0
Meters = 0.0
if choice == "C":
Celcius = fahrenheit_to_celcius(Fahrenheit,Celcius)
print (Celcius)
elif choice == "M":
Meters = feet_to_meters(Feet,Meters)
print (Meters)
elif choice == "E":
print("Thank you for using our program")
else:
print("Sorry you did not enter a C, M or E\nPlease try again: ")
choices()
return choice
def fahrenheit_to_celcius(Fahrenheit,Celcius):
Fahrenheit = 0.0
Celcius = 0.0
Fahrenheit = float(input("Enter Degrees Fahrenheit: "))
Celcius = (5/9)*(Fahrenheit-32)
return Celcius
def feet_to_meters(Feet,Meters):
Feet = 0.0
Meters = 0.0
Feet = float(input("Enter Feet: "))
Meters = (0.305*Feet)
return Meters
def main():
choice = ""
Feet = 0.0
Meters = 0.0
Fahrenheit = 0.0
Celcius = 0.0
choice = choices()
if __name__ == "__main__":
welcome()
choices()
You will probably not want to confuse your scopes again by having an unnecessary
choice parameter being passed that didn't actually do anything, then
choices = """ in the
choices() scope and globally.

I'm not actually sure where you want the loop or even if you just want it to run forever
Code
import string
def choices():
Fahrenheit = 0.0
Celcius = 0.0
Feet = 0.0
Meters = 0.0
choice = str(input("\nHere are your choices:\n\tC for Celcius\n\tM for Meters\n\tE for Exit\n\n")).upper()
while choice in list(string.ascii_uppercase):
if choice == "C":
Celcius = fahrenheit_to_celcius(Fahrenheit,Celcius)
print (Celcius)
choices()
elif choice == "M":
Meters = feet_to_meters(Feet,Meters)
print (Meters)
choices()
elif choice == "E":
print("Thank you for using our program")
break
else:
print("Sorry you did not enter a C, M or E\nPlease try again: ")
choices()
return choice
This post was edited by j0ltk0la on Jul 10 2015 09:51pm