Guess My Number:
After Codecademy Loops
Overview:
The computer randomly generates a number. The user inputs a number, and the computer will tell you if you are too high, or too low. Then you will get to keep guessing until you guess the number.
What you will be Using:
Random, Integers, Input/Output, Print, While (Loop), If/Elif/Else, Comparison operators, Booleans, Conditions
My Thoughts on Project:
If you are new to Python this is a great learning experience, remember the code you used here and how you used it. This will help your natural learning curve into Python.
Sample: Hello! What is your name?
Albert
Well, Albert, I am thinking of a number between 1 and 20.
Take a guess. You only have 6 tries.
10
Your guess is too high.
Take a guess.
2
Your guess is too low.
Take a guess.
4
Good job, Albert! You guessed my number in 3 tries!
or
You lost, Albert. You have used up all of your 6 tries. The answer was: 5.
Want to play again?
To get 100 on the Guess A Number Game you must limit the number of guesses the user can make. Good games are challenging, but not impossible. So don’t limit it too much or too little.
The computer randomly generates a number. The user inputs a number, and the computer will tell you if you are too high, or too low. Then you will get to keep guessing until you guess the number.
What you will be Using:
Random, Integers, Input/Output, Print, While (Loop), If/Elif/Else, Comparison operators, Booleans, Conditions
My Thoughts on Project:
If you are new to Python this is a great learning experience, remember the code you used here and how you used it. This will help your natural learning curve into Python.
Sample: Hello! What is your name?
Albert
Well, Albert, I am thinking of a number between 1 and 20.
Take a guess. You only have 6 tries.
10
Your guess is too high.
Take a guess.
2
Your guess is too low.
Take a guess.
4
Good job, Albert! You guessed my number in 3 tries!
or
You lost, Albert. You have used up all of your 6 tries. The answer was: 5.
Want to play again?
To get 100 on the Guess A Number Game you must limit the number of guesses the user can make. Good games are challenging, but not impossible. So don’t limit it too much or too little.
Hint
Hint:
Use randint
print "Guess a number between 1 and 100."
number=random.randint(1,100)
Or use a list
from random import choice
listNum = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
answer = choice(listNum)
###This is only one way to do it. There are many ways.
Use a while loop:
###Limit how many guesses the user has.
while guesses < 10:
Use randint
print "Guess a number between 1 and 100."
number=random.randint(1,100)
Or use a list
from random import choice
listNum = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
answer = choice(listNum)
###This is only one way to do it. There are many ways.
Use a while loop:
###Limit how many guesses the user has.
while guesses < 10: