[Tutor] variable * raw_input

Dewight Kramer dfkramer at ucdavis.edu
Tue Aug 7 21:28:59 CEST 2007


Hello,

So i am new to Python, and really to programming.  I picked up book  
and so far I like it. right now I am trying to figure out a problem  
that I cant.

It is a tipping program and I have assigned certain words to be a  
certain % and then I ask the user to type raw input of one of those  
names.   After which I am trying to mutiply the Bill by the Service  
quality.  But I dont understand something below is code.

Thanks
D

# Tip Calulator - Ver
# Challenges Ch2 - Question 3
# Developed by, Dewight
# Developed on, 8/7/2007


# establish variables
bill = float(0.0)
bad = float (0.0)
ok = float(0.10)
good = float (0.15)
great = float (0.20)
service="nothing"
tip = float ()
total = float ()

print "This is a tipping calculator."

bill = raw_input ("\nWhat was the total bill amount?  ")
service = raw_input("Please input one of the following to"+
                     " discribe the service:"+"\nbad\nok\ngood\ngreat 
\n")

tip = bill * service
total = bill + tip
print "Then you should leave a" + tip + "tip. This will bring the  
total to" + total +"."


raw_input("\n\nPlease press enter to exit.")


More information about the Tutor mailing list