Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 93 - 2619_PlusGPT V2.1_C-8
P. 93

    test Your skiLLs

                     1.  Tick ( ) the correct option.

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

                           (i)  if                                          (ii)  if…else
                          (iii)  if…elif…else                              (iv)  All of these

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

                           if (True):
                             print("Hello")
                        else:

                             print("Hi")
                           (i)  Hello                                       (ii)  Hi

                          (iii)  Hello Hi                                  (iv)  Nothing will print

                        c.  What is the answer of the expression, 2**2**2?
                           (i)  2                                           (ii)  16

                          (iii)  4                                         (iv)  8

                        d.  If a = 20 and b = 10, then what will be the output of the following code?
                              if (False):
                                  print(20 + 10)
                              else:
                                  print(20 - 10)
                           (i)  30                                          (ii)  20
                          (iii)  10                                        (iv)  Nothing will print

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

                                                               false, if, true, else

                        a.  The ______________ statement is the simplest conditional statement.
                        b.  In Python, the non-zero value is interpreted as ______________ .

                        c.  Decision statements may give the results true or ______________ .
                        d.  The ______________ block will be executed only if the if condition evaluates to false.

                     3.  Write 'T' for true and 'F' for false.

                        a.  The else block must always come before the if block in Python.                   ____________
                        b.  In Python, indentation is not necessary for writing if and if...else statements.    ____________

                        c.  The if…else statement is the simplest conditional statement.                     ____________

                                                                                        Conditional Statements in Python  91

| 88 89 90 91 92 93 94 95 96 97 98 |