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

#Logical Reasoning




              Chapter 6





              #Chapter Profile

                  Loop                                                  Types of Loops
                  Instructions for Correct Algorithm                    Using IF and IF-Then-Else Conditions




                             Take Off                                                  Century   #Critical Thinking
                                                                                          21 st
                                                                                         Skills  #Productivity & Accountability
                    If a = 8, b = 2 and c = 20, then what will be the output of the following statements?
                    1.  print(a > b and b < c)   =                  2.  print(a ** b + c)   =

                    3.  print(a, b, c)      =                       4.  print(a > b or b > c)  =

                    5.  print(a // b – 2 + c)    =





              Logical reasoning is an important skill in computer science. It helps us to think step-by-step, make
              decisions, and create clear instructions that a computer can follow. In this chapter, you will explore
              loops, types of loops, and how to write correct algorithms.

                   LOOP


              A loop allows a set of instructions or a block of code to be executed repeatedly. It helps in automating
              repetitive tasks and makes the code more efficient by avoiding the need to write the same instructions
              multiple times. For example, If you want to clap 5 times, you can use a loop instead of writing “clap” five
              times.
              Look at this example:

              Sohail has to paint these blank boxes to make a letter ‘U’
                                                                        Start
   79   80   81   82   83   84   85   86   87   88   89