Hi! vikas mohan wrote: > Hi all, this is my first program in python. > > It's a currency converter mini-program, but I am not getting the desired > output. What wrong am I doing here? > > *Program code:* > > #converts currencies to Indian rupees > > def print_options(): > print "Options:" > print " 'p' print options" > print " 'c' convert from US Dollars to Indian Rupees" > print " 'f' convert from Swedish Kronors to Indian Rupees" > print " 'g' convert from British Pound Sterling to Indian Rupees" > print " 'q' quit the program" > > def rupees_from_dollars(c_doll): > return 43*1 --*The function is supposed to multiply the value of
Here is the c_doll missing return 43*c_doll > dollars x 43(value of an Indian rupee) > *def rupees_from_kronor(f_kron): > return 8*f_kron -- *The function is supposed to multiply the value > of kronor x 8(value of an Indian rupee)* > def rupees_from_pounds(g_pound): > return 68*g_pound --*The function is supposed to multiply the value > of pounds x 68(value of an Indian rupee) * > > choice = "p" > while choice != "q": > if choice == "c": > Rupees = input("US Dollars:") Rupees contains the inserted value > print "Rupees:",--*The problem is here: I only get Rupees but Here just the Text"Rupees:" is printed print "Rupees:", rupees_from_dollars(Rupees) or print "Rupees: %d\n" % ( rupees_from_dollars( Rupees ) ) You have to call the function to get the converted value. > not the value multiplied as stated in the function. * > elif choice == "f": > Rupees = input("Swedish Kronor:") > print "Rupees:" --*The problem is here: I only get Rupees but > not the value multiplied as stated in the function. * > elif choice == "g": > Rupees = input("UK Sterling:") > print "Rupees:"--*The problem is here: I only get Rupees but not > the value multiplied as stated in the function. * > elif choice != "q": > print_options() > choice = raw_input("option:") > > ----------------------------------------- > > Much appreciate your help! > > VikasM > > ** > ** > > > ------------------------------------------------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor HTH Ewald _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor