[Tutor] Can I get some feedback on my currency converter program

Alan Gauld alan.gauld at freenet.co.uk
Sat Dec 10 01:22:58 CET 2005


> like in Java, i would like to have live currency quotes fed to my 
> function,

Look at the urllib module.
However I suspect you might be better working on the basics for a little
longer before getting too ambitious!

def rupees_from_dollars(d_doll):
    return 43*(d_doll)

You don;t need the () in the line above.
They are needed as part of the function definition but not
within the function unless you need to group things together.
Here you only have one value so there is no need for the ()


choice = "p"
while choice != "q":
    if choice == "$":
        Rupees = input("US Dollars:")
        print "Rupees:",rupees_from_dollars(Rupees)

It might be better toi choose a more apt name for the input
value - dollars in this case maybe? Then it would look like:

    if choice == "$":
        dollars = input("US Dollars:")
        print "Rupees:",rupees_from_dollars(dollars)

It just makes a bit more sense since the value being read is,
in fact, the dollar value not the Rupee value.

    choice = raw_input("Choose option:")

You could also put the raw_input statement inside your menu function
and have it return the chosebn value - just a thought.

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list