Page 121 - Touchpad_Plus_V3.2_Class 7
P. 121

b.   The second nested if indented block will run only when the first if condition evaluates
                          to be False.

                       c.  The if statement inside other if statement is called nested if.

                       d.  Both a. and c.

                    5.   Ravi wants to create a program in Python that assigns grades (A, B, C, and D) to the students
                       according  to their  percentage  of marks. Which of the following is the  best suitable option  to
                       achieve this?

                       a.  Simple if statement                          b.  The if…else statement

                       c.  The if…elif…else statement                   d.  None of these

                    6.  Which of the following conditional statements is used to test multiple conditions?

                       a.  if                                           b.  if...elif...else

                       c.  if...else                                    d.  All of these

                    7.  What will be the output of the following code?

                        if(True):
                               print(“Hello”)
                        else:

                               print(“Hi”)
                       a.  Hello                                        b.  Hello Hi

                       c.  Hi                                           d.  Nothing will print

                 B.  Fill in the blanks using the words given below:

                                                     Hints

                                                         True, top-down, elif, False




                    1.  If a conditional expression return ................................., statements inside the if block are executed.

                    2.  The else part is executed only when the condition specified with if returns ..................................
                    3.  The if…elif…else ladder follows a ................................. approach.

                    4.  There can be multiple ................................. blocks with the if block.

                 C.  Short answer type questions.

                    1.  What will be the output of the following code, if x = -10:
                      if (x > 10):

                          print("x is greater than 10")
                      elif (x < 10):


                                                                              Conditional Statements in Python       119
   116   117   118   119   120   121   122   123   124   125   126