Page 138 - Plus V4 with Adobe class 7
P. 138

Timeline


                    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.






               Choose the correct option.


               1.  Which of the following conditional statements is used to test multiple conditions?
                        a.  if                                         b.  if…else

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

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

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

                        a.  Hello                                      b.  Hi

                        c.  Hello Hi                                   d.  Nothing will print

               3.  Which of the following is not the conditional statement in Python?

                        a.  if Statement                               b.  if…else Statement

                        c.  if...elif...else Statement                 d.  None of these

               4.   What is the answer of the expression, 2**2**2?

                        a.  2                                          b.  16

                        c.  4                                          d.  8

               5.  If a = 20 and b = 10, then what will be the output of the following code:

                  if (false):
                       print(a + b)

                  else:
                       print(a – b)

                        a.  30                                         b.  20

                        c.  10                                         d.  Nothing will print




            136  Plus (Ver. 4.0)-VII
   133   134   135   136   137   138   139   140   141   142   143