349,089 views
41 votes
41 votes
I didnt understand what the assignment is asking me to do. Can someone please explain? Thanks

I didnt understand what the assignment is asking me to do. Can someone please explain-example-1
User SAbbasizadeh
by
2.7k points

2 Answers

15 votes
15 votes
I think you have to create the same guessing game in Python
User Krzysztof Miksa
by
2.7k points
26 votes
26 votes

Answer:

The pseudocode describes a program that plays a guessing game with the user. The computer will pick a random number between 1 and 100, and the user will try to guess what the number is. The program will keep track of the number of guesses the user makes, and will continue to ask the user for their guess until they correctly guess the number that the computer has chosen.

To implement this program in Python, you will need to follow these steps:

  1. Import the random module, which will be used to generate a random number for the computer to pick.
  2. Initialize variables for pick, guess, and count to 0. pick will be the number that the computer has chosen, guess will be the user's guess, and count will be the number of guesses the user has made.
  3. Use the random.randint() function to generate a random number between 1 and 100 and assign it to the pick variable.
  4. Print a message to the user explaining the rules of the game.
  5. Inside a while loop, ask the user to input their guess and assign it to the guess variable.
  6. Increment the count variable to keep track of the number of guesses the user has made.
  7. If the user's guess is less than the number the computer has picked, print a message telling the user to try again with a higher number. If the user's guess is greater than the number the computer has picked, print a message telling the user to try again with a lower number.
  8. The while loop will continue to run until the user's guess is equal to the number that the computer has picked. When the user's guess is correct, the loop will exit and the program will print a message telling the user that they have guessed correctly and the number of guesses it took them.

I hope this helps! Let me know if you have any questions.

User Tanishq Vyas
by
2.8k points