Page 105 - modular4.0
P. 105

Chapter Profile
                     3.       Program.py

                           File  Edit  Format  Run   Options   Window   Help

                           k=79
                           if(k>50):
                               if(k<60):
                                   print('One')
                               else:

                                   print('Two')
                           else:
                               if(k>30):
                                   print('Three')
                               else:
                                   print('Four')





                         What is the output of this program?
                         a.  One                                        b.  Two

                         c.  Three                                      d.  Four

                     4.    Which of the following is correct syntax of if else?
                         a.  if condition then:                         b.  if condition
                             # block of code                               # block of code
                             else then:                                    else
                             # block of code                               # block of code


                          c.  if condition:                             d.  if condition:
                             # block of code                                   # block of code

                              if not condition:                            else:
                             # block of code                                   # block of code

                     5.  What will happen if the condition in an if statement is False?
                         a.  The code after the if block will always run.
                         b.  The code inside the else block will execute, if present.

                         c.  The program will stop.

                         d.  An error will occur.
                 B.   Fill in the blanks using the words given below:


                                                    false, Conditional statements, if, :
                     1.                      decide the flow of program execution.

                     2.   In case the if condition evaluates to              , then the control of execution is passed to
                         the next statement after the if block.







                                                                                      Conditional Statements in Python  103
   100   101   102   103   104   105   106   107   108   109   110