ModdersCentral

Full Version: Python Measurement Conversion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
def miles_to_kilometres(value): 
    return value * 1.6
def kilometres_to_miles(value): 
    return  value * 0.62
def centimetrestoinches(value): 
    return value * 0.39
def inchestocentimetres(value): 
    return value * 2.54


print("what option do you choose?")
print("1. Convert Miles to Kilometers")
print("2. Convert Kilometers to Miles")
print("3. Convert CM to Inches")
print("4. Convert Inches to CM")

option = input("? ")
number = float(input("measurement? "))


if option=="1": 
    print( number  , " miles in kilometres is " , miles_to_kilometres(number)) 
elif option=="2": 
    print( number  , " kilometres in miles is " , kilometres_to_miles(number)) 
elif option=="3": 
    print( number  , " CM in inches is " ,  centimetrestoinches(number))  
else: 
    print( number  , " inches in CM is " , inchestocentimetres(number)) 
www.000webhost.com