This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Measurement Conversion
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))  
    print( number  , " inches in CM is " , inchestocentimetres(number)) 
Disclaimer: Don't be misguided looking at my usergroup and assume whatever I say is official. When I speak in community I am just a member with personal opinions.

Forum Jump:

Users browsing this thread: 1 Guest(s)