Page 120 - Touchpad_Plus_V3.2_Class 7
P. 120

Restart


                        The if statement is the simplest conditional statement.
                         In the if…else statement, if the condition evaluates to True, the indented block following
                       the if statement is executed, otherwise the indented block after the else statement is

                       executed.
                         Python allows the nested if statement.
                         The if…elif…else  ladder helps  us  to test multiple  conditions and follows  a top-down

                       approach.




                                                           Checkpoint





                  A.  Tick ( ) the correct option.

                     1.  What will be the output of the following code:
                      x = 10
                      if x > 5:
                          print("x is greater than 5")

                         a.  x is greater than 5                          b.  10 is greater than 5

                         c.  Nothing will be printed                      d.  None of these

                     2.  What will be the output of the following code if x = 3:

                        if (x % 2) == 0:
                            print("x is even")

                        else:

                            print("x is odd")
                         a.  x is even                                    b.  x is odd
                         c.  Both a. and b.                               d.  None of these


                     3.  Which of the following is the result of a conditional expression?
                         a.  Always True                                  b.  Always False

                         c.  Either True or False                         d.  Neither True nor False

                     4.  Which of the following statement is true about nested if statement?
                         a.   The second nested if indented block will run only when the first if condition evaluates
                           to be True.





               118      Plus (Ver. 3.2)-VII
   115   116   117   118   119   120   121   122   123   124   125