At Westonci.ca, we provide reliable answers to your questions from a community of experts. Start exploring today! Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.
Sagot :
Answer:
I'll write some pseudo-code, you can convert it into Python. // means I've wrote a comment explaining what is going on. Don't overcomplicate things when you write code!
Start
Declare Num as Integer // Defines a variable called Num
// Here you put your code to generate a random number
Num = random number between 1 to 20
Declare Guess as Integer
Declare CorrectGuess as Boolean // Boolean variables are either true or
false.
CorrectGuess = False
// To keep track of how many guesses it takes them
Declare GuessCount as Integer = 0
Declare Score as Real = 0 // Real means the number can be a decimal.
While CorrectGuess = False: // keep looping until correct.
GuessCount = GuessCount + 1 // Increases the guess count by 1.
output("What's your guess?") // asks the user what their guess is.
input(Guess) // Allows the user to input their guess.
If Guess = Num Then // Using a condition to decide if the
guess is correct.
output("Correct, my number was " + Num") // correct output
//output GuessCount
output("It took you " + GuessCount + " guesses!")
CorrectGuess = True // Now the while loop won't run again.
Else If Guess > Num Then // If the guess was larger than the number
output("Your guess was too large! Try again.")
Else If Guess < Num Then // If the guess was smaller than the number
output("Your guess was too small! Try again.")
Else
End If
End While
Score = (GuessCount / 20) * 100 // Calculate the users score.
Round(Score) // Round the score to 0 decimal places.
End
Hope you can understand this. I think followed all of the stages and if something is incorrect don't hesitate to tell me.
We hope our answers were helpful. Return anytime for more information and answers to any other questions you may have. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.