Page 138 - KEC Khaitan C8 Flipbook
P. 138

PROJECT NAME: Guess The Number (Single Attempt)

                  Software Used: Python Editor

                  Objective:

                  Create a Python program that simulates a guessing game. The computer randomly selects a
                  number within a given range, and the user attempts to guess it correctly.
                  Platform:

                     ∑  PyCharm

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


                  Step-by-Step Instructions


                  Plan IPO Framework
                  Step  1   Input:

                               The program defines a fixed range for the guessing game (e.g., 1 to 100).

                                The computer makes a random selection within the range using Python’s random
                               library.

                               The user enters their guess.

                  Step  2   Process:

                               The program compares the user’s guess with the computer's choice.

                               Based on the comparison:
                               o  If the guess is too low, prompt the user with: "Too low, try again."

                               o  If the guess is too high, prompt the user with: "Too high, try again."

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

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

                  Step  3   Output:

                                Display the appropriate message based on the user's input and comparison with the
                               computer's choice.
                                Code:















                  136   Premium Edition-VIII
   133   134   135   136   137   138   139   140   141   142   143