[Tutor] calling and returning functions.

Pravya Reddy pravyareddy at gmail.com
Mon Feb 11 21:07:16 CET 2013

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
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
            number = int(said)
        except ValueError:
                print (said, "is not a number.")
                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")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130211/e0d4468a/attachment.html>

More information about the Tutor mailing list