06.0 Python‎ > ‎Python Projects‎ > ‎Guess It Project‎ > ‎

Guess It v1-Get It Right


The student will practice the following skills:
  • conditional loop -- do the CS Circles tutorial 7C
  • while statement

Project Description:

Modify Guess It v0 so the program will keep asking the user for a guess until the user correctly guesses the secret number. Careful, do not change the secret number until the user guesses correctly.

Add two method calls 
to get the users second third ... guess

Code hints: It is important to understand the flow of this code and the logic behind it!
def playGuessIt(): 
        pre-condition: None 
        post condition: one game of Guess has been played 
    # set the secrete number and get the first guess 
    # this is called "priming the loop" 
    while isNotCorrect(guess, secret): 
        #the guess is not correct, so issue a hint 
        # ask the user for a new guess 

    # since the execution is in the loop until a correct guess is made 
    # the guess must be right 

Part 2

Count the number of times the user needs to guess the correct number