Can you please complete the code.
#!/usr/bin/env python
""" One function receives a value in inches and returns the equivalent
value in
cms like cm = 2.54 * in.The other function receives a value in cms and
returns
the equivalent value in inches like in = cm / 2.54."""
def conversion(inch,cm):
"""returns the value in cm and in."""
return (2.54 * float(inches))
return (float(cm) / 2.54)
def GetInt(prompt):
"""Returns a number, or None if user doesn't answer."""
while True:
said = input(input(prompt))
if not said:
return None
try:
number = int(said)
except ValueError:
print (said, "is not a number.")
continue
return number
def Test():
first = GetInt('Please enter inches:')
if first:
second = GetInt('Please enter cms:')
print(first, "*", 2.54, "=", "cms")
print(second, "/", 2.54, "=", "in")
Test()
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor