<jupyter_start><jupyter_text>Now You Code 4: Guess A NumberWrite a program to play the classic "Guess a number" game.In this game the computer selects a random number between 1 and 10.It's your job to guess the number. Whenever you guess, the computer willgive you a hint of higher or lower. This process repeats until you guessthe number, after which the computer reports the number of guesses it took you.For Example:I'm thinking of a number between 1 and 10...Your guess: 5Too low. Guess higher.Your guess: 7Too high. Guess lower.Your guess: 6You guessed it in 3 tries.Your loop should continue until your input guess equals thecomputer generated random number. How do you make Python generate a random number?<jupyter_code># Sample code which demostrates how to generate a number between 1 and 10
import random 
number = random.randint(1,10)
print(number)<jupyter_output>4<jupyter_text>Run the cell above a couple of times. Notice how each time you execute the code, it comes up with a different number. Here's a breakdown of the code```line 1 imports the random moduleline 2 randomly selects an integer between 1 and 10line 3 prints the number```Now that you understand how to generate a random number, try to design then write code for the program. The first step in your program should be to generate the random number.  Step 1: Problem Analysis Inputs:Outputs:Algorithm (Steps in Program):<jupyter_code># Step 2: write code for program
import random 
cpu = random.randint(1,10)
user=input("guess the number:")
c=1
try:
    while int(user)!=cpu:
        c=c+1
        if int(user)>cpu:
            print("estimate is too high")
        else:
            int(user)<cpu
            print("estimate is too low")
        user=input("enter another value:")
    print("you guessed the number congrats I guess")
    print("you guessed the number in",c,"tries")
except:
    print("error")<jupyter_output>guess the number:1
estimate is too low
enter another value:10
you guessed the number congrats I guess
you guessed the number in 2 tries<jupyter_text>Step 3: Questions1. Which loop did you use to solve the problem? What is a definite or indefinite loop?indefinite loop2. Modify this program to allow you to guess a number between 1 and 100. How much of your code did you need to change to make this work? only one line3. This program is a good example of a difficult problem to conceptualize which has a simple solution when you look at actual lines of code. I assume you did not write this in a single try, so explain where you got stuck and describe your approach to overcoming it.infinite loop in while statementI needed to ask the user for an input to stop the infinite loop  Reminder of Evaluation Criteria1. What the problem attempted (analysis, code, and answered questions) ?2. What the problem analysis thought out? (does the program match the plan?)3. Does the code execute without syntax error?4. Does the code solve the intended problem?5. Is the code well written? (easy to understand, modular, and self-documenting, handles errors)<jupyter_code>import random 
cpu = random.randint(1,10)
user=input("guess the number:")
c=0
while int(user)!=cpu:
    c=c+1
    if int(user)>cpu:
        print("estimate is too high")
    else:
        int(user)<cpu
        print("estimate is too low")
    user=input("enter another value:")
print("you guessed the number congrats I guess")
print("you guessed the number in",c,"tries")<jupyter_output>guess the number:1
estimate is too low
enter another value:5
estimate is too low
enter another value:8
you guessed the number congrats I guess
you guessed the number in 2 tries
{'fraction_non_alphanumeric': 0.06236203090507726, 'fraction_numerical': 0.015728476821192054, 'mean_word_length': 4.2688953488372094, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '261037', 'license': 'MIT', 'n_tokens_mistral': 1018, 'n_tokens_neox': 959, 'n_words': 523, 'path': 'content/lessons/05/Now-You-Code/NYC4-Guess-A-Number.ipynb', 'repo_name': 'MahopacHS/spring2019-guot-su', 'size': '3624'}