Python | Pies

/ 7 Jul 2013 /
This is my fourth program, and it is just a basic buying program, which lets you buy pies..(virtual pies) and the more pies you buy, the cheaper they are, so let's say 1 pie is $5? 2 pies would be $7.5, and so on. One problem I had with this program is I couldn't get it to stop after it hit 0, so it just printed negative numbers according to how many pies are bought. I was pretty proud of this one.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
buy = 0
pies = 50
cost = 5
while 1:
    print("We have ", pies, "pie(s) left!")
    buy = int(input("How many pies would you like?  "))   
    price = cost * buy
    if buy == 1:
        print(price)
        pies -= 1
    elif buy > 1:
        print(buy * cost * 0.75)
        pies -= buy
    else:
        print("Please enter how many pies you would like!")
 
Copyright © 2010 M(ath)+me, All rights reserved