Ask Question
29 August, 09:04

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?

+2
Answers (1)
  1. 29 August, 09:35
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers