While Loop - Python
While Loop - Python
Direction:
1.Start by setting a variable, ‘count’, to 1.
2.Use a while loop that continues as long as ‘count’ is less than or equal to 10.
3.Inside the loop, use the print function to display the value of ‘count’. After
printing, increase the value of ‘count’ by 1 to move to the next number.
4.The loop automatically stops when ‘count’ exceeds 10.
Assignment: Guess the number
Create a number guessing game in Python that:
• Generates a random number between 1 and 20.
• Prompts the user to guess the number.
• Provides feedback if the guessed number is too high or too low.
• Continues prompting until the correct number is guessed.
• Prints a congratulatory message with the number of attempts once guessed correctly.
Requirements:
• Use a while loop for continuous prompting.
• Implement input validation for valid number inputs within the range.
• Display appropriate messages to guide the user.
Hints:
• Utilize Python's random module for generating the number.
• Use input() for user input and int() to convert input into an integer.
Submission: Submit your Python script (.py file) containing the game implementation and any additional comments
explaining your code.