#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    10
    Rep Power
    0

    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 "-----------"
    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. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    10
    Rep Power
    0
    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
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    14
    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.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    10
    Rep Power
    0
    thxs i was tried last night and didnt see that :P

IMN logo majestic logo threadwatch logo seochat tools logo