|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Multiplying in python?
I have to make this prog work, but I keep getting errors.Please some one look at this and tell me whats wrong with the code?
print "-----------" print "Priceticket" print "-----------" ques = ("What was the cost of the ticket?") T = ques * 0.07 I = ques G = ques % (0.07) print " -----------------------------------------" print "| Pricebusters! |" print "|-----------------------------------------|" print "| Item Cost | GST | Total Price |" print "|-------------+---------+---------------|" print "| ,I | ,G | ,T |" print " ----------------------------------------" |
|
#2
|
|||
|
|||
|
NM I found out that it was my printing it shouls be like this:
print "|",I ,"|$",G ,"|$",T ,"|" to make it print right blaa too tired :P |
|
#3
|
|||
|
|||
|
Uh, that and you aren't taking any input ... so ... it's not just that you were printing things wrong, but I see no raw_input() in there. Also, the easier way of doing the output is to use string formatting:
Code:
print "| %.2f | $%.2f | $%.2f |" % (I, G, T) For example: Code:
>>> I = 2.0; G = 3.0; T = 4.0 >>> print "| %.2f | $%.2f | $%.2f |" % (I, G, T) | 2.00 | $3.00 | $4.00 | And also, you might consider better variable names. |
|
#4
|
|||
|
|||
|
thxs i was tried last night and didnt see that :P
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Multiplying in python? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|