# Limit 33

“Limit 33” is a simple game of adding a series of random numbers to a running total. The player’s aim it to reach a total as close as possible to 33 without taking this total over 33.

#### Rules of the Game

1. A player starts with a total of zero.
2. On each turn a random number between 1 and 10 is generated and added to the player’s total.
3. If the player’s total exceeds 33, the player has lost and the game ends: Game Over.
4. At the end of each turn the player is asked whether they want to complete another turn or quit.
5. If they quit, the player is given a score as follows:
• Zero point if their total is below 24 or above 33.
• 10 x (total – 23) points if their total is between 24 to 33.
• For instance with a total of 29, the player would score 10 x (29-23) = 60 points. The maximum score they can reach is 10 x (33-23) = 100 when they reach a total of 33!

#### Flowchart

For this challenge, you will create the Python code for this game. You can use the flowchart given above to help you with your code.

[pms-restrict display_to=”not_logged_in” message=” “]

#### Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
[/pms-restrict] [pms-restrict subscription_plans=”14217″ message=” “]

#### Solution...

You are viewing this solution as part of your full membership subscription!

Python Code

#### Python Code

```# Limit 33 - www.101computing.net/limit-33/
import random

score = 0
total = 0

while (total<33 and carryOn=="yes"):
randomNumber = random.randint(1,10)
total = total + randomNumber
print ("Your total is:" + str(total))
carryOn = input("Do you want to carry on?")

if total<24:
print "Game Over!"
print "Zero point scored"
elif total>33:
print "Game Over!"
print "You have exceeded 33!"
print "Zero point scored"
else:
print "Game Over!"
score = 10 * (total -23)
print "Your score: " + str(score)
```
[/pms-restrict]

Did you like this challenge?

Click on a star to rate it!

Average rating 4.2 / 5. Vote count: 14

No votes so far! Be the first to rate this post.

As you found this challenge interesting...