Page 91 - 2502_Pakistan-kifayat_C-7
P. 91

Double Tap                                                   Century   #Critical Thinking
                                                                                         21 st
                                                                                         Skills
                        Write the output of the following statements:

                         1.  if (today is Sunday) then                 2.  if (a>90) then
                               print "Weekend"                              print "Excellent"
                           else                                          else
                               print "No weekend"                            print "Try harder"

                           Assume that today is Sunday                  Assume that the value of a is 85.






                 Once you understand how conditions work, you can guess the output based on different inputs. This
                 is called logical reasoning.

                 For example,

                 if marks ≥ 40 then

                   print "Pass"

                 else
                   print "Fail"
                 Try these inputs:

                    Marks = 75 Æ Output: Pass

                    Marks = 28 Æ Output: Fail

                    Marks = 40 Æ Output: Pass
                 By checking the condition, you can predict the correct output.



                           Timeline

                            A loop allows a set of instructions or a block of code to be executed repeatedly.

                            Loops are classified on the basis of how many times they repeat — one is finite and the other is
                          infinite.
                            A finite loop is a type of loop that repeats a set of instructions for a fixed number of times.
                            An infinite loop, on the other hand, keeps repeating the instructions forever unless it is manually
                          stopped or interrupted by a condition.
                            An algorithm is a list of clear and step-by-step instructions to solve a problem or complete a task.
                            The if statement is the simplest conditional statement.








                                                                                                 #Logical Reasoning  89
   86   87   88   89   90   91   92   93   94   95   96