انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Python: home
0. Lab tour1
1. The start5
2. Variables and input5
3. Conditions5
4. Loops5
5. Lists4
6. Functions4
7. Drawing with the turtle3
8. The project: the guess-the-number game3
9. Strings in depth1
10. Dictionaries (dict)3
11. Randomness and errors3
12. Classes and objects (class)2
13. Pro drawing and charts3
14. The final project: the quiz game2

The idea and the plan

Section 8: The project: the guess-the-number gameLesson 8.1 · ⏱ 6 min

The computer picks a secret number from 1 to 20, and the player guesses. After every guess the program says: bigger or smaller, until the player gets it.

  • 🎲 random.randint(1, 20) picks the number.
  • 🔁 while True repeats until the player gets it, then break.
  • 🧮 A tries variable counts the tries.
Finished the lesson? Mark it so your progress counts.