Page 86 - CodePilot V5.0 C7
P. 86

21 st
                       EXPERIENTIAL LEARNING                                                  Century   #Critical Thinking                                                             ACTIVITY-4
                                                                                               Skills

                    Create a list of students with their names, roll numbers and another column where their first name
                    and roll number are combined.  Identify the pattern Excel uses to automatically combine the data.                           Design an algorithm for a number-guessing game
                                                                                                                                                in which the player must enter a number between
                                                                                                                                                10 and 20. If the player enters a number within this
                                                                                                                                                range, the game should display a congratulations
                                                                                                                                                message and stop. If the number is outside the
                         USING LOOPS AND CONDITIONS IN ALGORITHMS                                                                               range, the game should prompt the player to try

                                                                                                                                                again until a valid number is entered. Break the
                  Loops and conditions help you solve problems by repeating tasks and making decisions. A loop                                  game into clear, step-by-step instructions.
                  repeats a set of instructions multiple times. This is useful when you need to do the same task many
                  times, like printing numbers, filling shapes or repeating actions.

                  Let’s say you want to create a row of 5 stars:

                                           Without a loop               With a loop
                                               Print a star         Repeat 5 times:                                                                                                    ACTIVITY-5

                                               Print a star        •  Print a star                                                              Create a flowchart for a Number-Guessing Game on ACTIVITY-4.
                                               Print a star

                                               Print a star

                                               Print a star
                  Using a loop helps you save time and effort because you don’t have to write the same instruction

                  over and over again.
                  Conditions, on the other hand, help the program make decisions. They check if something is true
                  or false and based on that, the program decides what to do next.

                  The most common condition is the If-Then-Else structure, where:

                      If the condition is true, do one thing.

                      Else (if the condition is false), do something else.
                  Lets check if a number is positive or negative.                                                                                  EVALUATION

                  READ number
                                                                                                                                            Evaluation involves testing different solutions, comparing them and choosing the best one based
                  IF number > 0 THEN
                                                                                                                                            on efficiency, accuracy and smartness. When solving a problem, there are often multiple ways to
                      PRINT "The number is positive."                                                                                       approach it. To evaluate solutions, ask yourself:
                  ELSE                                                                                                                           Efficiency: How quickly can the task be completed?
                                                                                                                                                 Accuracy: Does the solution give the correct result?
                      PRINT "The number is negative."
                                                                                                                                                 Smartness: Is the solution simple, using fewer steps or resources?
                  The  above  algorithm,  checks  if the given number  is greater than 0 or not. If  the condition  is
                  true (i.e., if the number is positive), it prints: “The number is positive.” If the condition is false                    For example, if you are sorting a list of names, you could try different sorting methods and select
                  (i.e., if the number is negative or zero), it prints: “The number is negative.”                                           the one that is fastest, most accurate and easiest to implement. Evaluation ensures that the
                                                                                                                                            solution is not only correct but also practical and optimal.




                   84
                        CodePilot (V5.0)-VII
   81   82   83   84   85   86   87   88   89   90   91