2 of 1 ·Number guessing game

Lesson 2 · Python Foundation
Mini project using a loop.
Loops
Use a for loop to repeat a known number of times. First print a greeting three times. A while loop keeps going while its condition is true, so plan how it will stop.
Click to zoomThis project uses every single thing you've learned in Python: variables, input, conversion, conditions, loops.
The computer picks a secret number. The player guesses. After each guess they're told higher or lower, until they get it.
And there's a bonus: the smart way to play this game is the halving search from Chapter 2 — the phone book trick. You're about to build the game that proves why it works.
9 more parts in this lesson
Walkthroughs, code labs, mini-games and the checkpoint quiz unlock when you buy the course.