Line 77: |
Line 77: |
| <pre> | | <pre> |
| #!/usr/env python | | #!/usr/env python |
| + | # -*- coding: cp1252 -*- |
| + | import random |
| | | |
| name = 'Lemonade Stand' | | name = 'Lemonade Stand' |
Line 92: |
Line 94: |
| | | |
| return in_text | | return in_text |
| + | |
| + | def random_Event(): |
| + | global stored_sugar, stored_lemons, stored_cups |
| + | event = random.randint(0, 10) |
| | | |
| + | if event == 0: |
| + | |
| + | if stored_sugar > 10: |
| + | stored_sugar -= 10 |
| + | print 'Ants steal your supplies!' |
| + | else: |
| + | stored_sugar = 0 |
| + | |
| + | elif event == 1: |
| + | |
| + | print 'A lemon truck crashes in front of your stand!' |
| + | stored_lemons += 10 |
| + | |
| + | elif event == 2: |
| + | |
| + | print 'It starts raining cups!' |
| + | stored_cups += 10 |
| | | |
| + | def supply_Decay(): |
| + | return 'hello' |
| + | |
| + | |
| # default values | | # default values |
| cup_price = .25 | | cup_price = .25 |
Line 112: |
Line 139: |
| | | |
| for day in range(1, num_days + 1): | | for day in range(1, num_days + 1): |
| + | |
| + | random_Event() |
| + | |
| | | |
| print "" | | print "" |
Line 120: |
Line 150: |
| print "You have "+`stored_cups`+" cups, "+`stored_lemons`+" lemons, and "+`stored_sugar`+" sugar left." | | print "You have "+`stored_cups`+" cups, "+`stored_lemons`+" lemons, and "+`stored_sugar`+" sugar left." |
| | | |
− | print "Cup price: $"+`cup_price` | + | print "Cup price: $" + `cup_price` + " Lemon price: $"+ "%.2f" % lemon_price + " Sugar price: $"+ "%.2f" % sugar_price |
− | print "Lemon price: $"+`lemon_price` | |
− | print "Sugar price: $"+`sugar_price`
| |
| | | |
| expenses = 0 | | expenses = 0 |
Line 155: |
Line 183: |
| stored_lemons -= sales | | stored_lemons -= sales |
| stored_sugar -= sales | | stored_sugar -= sales |
− | print `sales`+" cups made for $"+`expenses` | + | print `sales`+" cups made for $"+ "%.2f" % expenses |
| | | |
| profit = sales * product_price | | profit = sales * product_price |
− | print `sales`+" cups were sold today for $"+`profit` | + | print `sales`+" cups were sold today for $"+ "%.2f" % profit |
− | print "You made $"+`(profit - expenses)`+" today." | + | print "You made $"+ "%.2f" % (profit - expenses)+" today." |
| bank += profit - expenses | | bank += profit - expenses |
− | print "Current funds: $"+`bank` | + | print "Current funds: $"+ "%.2f" % bank |
| + | |
| + | |
| + | |
| + | print |
| + | |
| print "Done!" | | print "Done!" |
| + | |
| + | |
| | | |
| | | |
| </pre> | | </pre> |