Line 49: |
Line 49: |
| <pre> | | <pre> |
| #!/usr/env python | | #!/usr/env python |
| + | |
| + | name = 'Lemonade Stand' |
| + | |
| + | print 'Welcome to ' + name |
| + | |
| | | |
| def take_input(text, default = 0): | | def take_input(text, default = 0): |
Line 55: |
Line 60: |
| except: | | except: |
| return default | | return default |
| + | if in_text < 0: |
| + | in_text = 0 |
| + | |
| return in_text | | return in_text |
| + | |
| + | def random_event( ): |
| + | |
| | | |
| # default values | | # default values |
Line 72: |
Line 83: |
| | | |
| # take in input | | # take in input |
− | num_days = take_input("How many days", 30) | + | num_days = take_input("How many days would you like to play for?", 30) |
| | | |
| for day in range(1, num_days + 1): | | for day in range(1, num_days + 1): |
| | | |
− | print "Day number "+`day` | + | print "" |
− | | + | print "____________________" |
| + | print " Day number " + `day` |
| + | print "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯" |
| + | print "" |
| 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." |
| | | |
Line 87: |
Line 101: |
| | | |
| in_num = take_input("How many cups") | | in_num = take_input("How many cups") |
| + | |
| expenses += in_num * cup_price | | expenses += in_num * cup_price |
| stored_cups += in_num | | stored_cups += in_num |
Line 108: |
Line 123: |
| #default value | | #default value |
| requested_sales = 5 | | requested_sales = 5 |
− | sales = min(today, requested_sales) | + | sales = max(min(today, requested_sales),0) |
| | | |
| # Option 2: make as many as requested | | # Option 2: make as many as requested |
Line 122: |
Line 137: |
| print "Current funds: $"+`bank` | | print "Current funds: $"+`bank` |
| print "Done!" | | print "Done!" |
| + | |
| + | |
| </pre> | | </pre> |
| | | |