Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 114 - 2625 PortGPt V2.1
P. 114

    test Your skiLLs

                      1.  Tick ( ) the correct option.
                          a.   What will be the output of the following code:

                               x = 10

                               if x > 5:
                                   print("x is greater than 5")

                               (i)   x is greater than 5                      (ii)  10 is greater than 5
                               (iii)  Nothing will be printed                 (iv)  None of these
                          b.  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")
                               (i)   x is even                                (ii)  x is odd

                               (iii)  Both (i) and (ii)                       (iv)  None of these

                          c.   Which of the following is the result of a conditional expression?

                               (i)   Always True                              (ii)  Always False
                               (iii)  Both (i) and (ii)                       (iv)   Either True or False

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

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

                               (iii)    The if statement inside other if statement is called nested if.

                               (iv)   Both (i) and (iii)

                          e.    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?
                               (i)   Simple if statement                      (ii)   The if…else statement

                               (iii)  The if…elif…else statement              (iv)  None of these

                      112   Premium Edition-VII

| 109 110 111 112 113 114 115 116 117 118 119 |