Ask Question
10 March, 14:00

Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correct answer. But when Adam tests the program, it always outputs that it took the user one guess, even when it takes many guesses. What error did Adam most likely make, and how should it be fixed?

+4
Answers (1)
  1. 10 March, 17:07
    0
    This is the game guess the number. The computer ask you. Hey! I have thought of a number in between 1 and 20. Can you guess what the number is? If you predict correct, Computer says you guessed right and in so and so number of times. Or else if your guess is larger than guess than it says your guess is too high and it says too low if guessed number is less than the guess. However, in this program it always says it guessed right in one attempt. Actually, we use here if else ladder, The problem is in this if else ladder expression. It has not been set properly. Hence, Adam needs to check that part of the program.

    if guessd_number = = guess:

    attempt++

    print ("you guessed right in" + attempt+"attempts)

    elif guessed_number < guess:

    attempt++

    print ("your guess is too low")

    else:

    attempt++

    print ("your guess is too high")

    And this will be inside a while loop. The problem is definitely here.

    Explanation:

    The answer is self explanatory.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correct answer. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers