Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 146 - 2615_KEC
P. 146

    PROJECT 2: Guess The Number (Continuous Attempt)

                      Software Used: Python Editor

                      Objective:
                      Develop a Python program to simulate a guessing game where the computer randomly selects

                      a  number  within  a  fixed range. The user  repeatedly  guesses  until  they  correctly  identify  the
                      computer's choice.
                      Platform:

                      PyCharm

                      Google Colab: https://colab.research.google.com/

                      Step-by-Step Instructions

                      Plan IPO Framework
                      Step  1   Input:

                                   Define a fixed range for the game (e.g., 1 to 100).

                                   The computer randomly selects a number using Python’s random library.

                                   The user enters their guesses.

                      Step  2   Process:

                                   Continuously compare the user’s guess with the computer's number until it matches:
                                   o  If the guess is too low, display: "Too low, try again."

                                   o  If the guess is too high, display: "Too high, try again."

                                   o   If the guess is out of range, display: "Invalid guess. Please enter a number within
                                      the range."

                                   o  If the guess is correct, display: "Congratulations! You've guessed it right."

                                   Repeat the process until the correct number is guessed.

                      Step  3   Output:

                                   Provide feedback on whether the guess was too low, too high, invalid, or correct.
                                    Code:

                      144   Premium Edition-VIII

| 141 142 143 144 145 146 147 148 149 150 151 |