Write a program to play a guessing game using random module?
Answer / Mayank Tripathi
To create a simple number-guessing game using the `random` module, you can generate a random number and ask the user to guess it. Here's an example:n```pythonnimport randomnsecret_number = random.randint(1, 20)n# Ask for user input until they guess correctlynwhile True:n guess = int(input('Guess a number between 1 and 20: '))n if guess == secret_number:n print('Congratulations! You guessed the number.')n breakn else:n print('Sorry, that is not correct. Try again.')```
| Is This Answer Correct ? | 0 Yes | 0 No |
Python or r: which one would you prefer for text analytics?
Which method removes and returns last object of a list?
What does means by split do in python?
Is python as powerful as c++?
How useful is python?
Write a program structure in python?
Does python have private variables?
Explain Inheritance in Python?
is there any maximum length expected for an identifier?
Differentiate list and tuple with an example?
What is python rest api?
What is the difference between and ?