Page 58 - Computer Genius Class 07
P. 58

The above mentioned logic can be applied through if-else statement. The if-else statement requires
                  three things:
                      Evaluation statement: Condition or expression that is being checked.

                      Execution statement: Operations which will be performed if the condition appears to be true.
                      Else execution block: Operation which will be performed only if the evaluation statement is false.

                  ELSE-IF Statement
                  Suppose you need to compare two numbers a, b and check if a is greater than b or they are equal.
                  To implement this, you need to check two conditions.

                  In python, the keyword elif, is used for checking another statement in case the previous statement
                  is false. In python, elif is short for else-if.
                  Code:

                  a=23
                  b=23
                  if a>b:

                      print (“a is greater than b”)
                  elif a==b:
                      print (“a is equal to b”)

                  else:
                      print (“a is less than b”)
                  Explanation: In this, you are comparing the values of two variables by using a comparison operator.
                   n the first statement it chec s i  a is greater than    i  this condition is true then it print   a is
                  greater than b”), and if the condition is false, then “elif” block will execute and checks if a is equal
                  to b, if it is true, then it prints (“a is equal to b”) and if it is false then it print (“a is less than b”).






                      Alan Turing, the father of modern computer science was famous for developing
                      the first modern computer.





                                                                                       Information Literacy
                        Quest                                                          Media Literacy



                         State whether the following statements are true (T) or false (F).

                         1.  Control structure is a basic decision-making process.
                         2.   Selection statement executes a set of statements for a certain
                             number of times.





                       56    Computer Genius-VII
   53   54   55   56   57   58   59   60   61   62   63