Page 109 - TP_V5.1_C7_fb
P. 109

c.  Write the syntax of the following:

                      (i)  if statement
                      ______________________________________________________________________________________

                      ______________________________________________________________________________________

                       (ii)  Nested if statement
                      ______________________________________________________________________________________
                      ______________________________________________________________________________________

                    d.  How are sequential statements different from selection statements?
                      ______________________________________________________________________________________

                      ______________________________________________________________________________________

                      ______________________________________________________________________________________

                 5.  Write the output of the following codes:
                    a.  l = 29

                     m = 29

                     if m > l:
                             print("m is greater than l")
                     elif l == m:
                             print("l and m are equal")
                      ______________________________________________________________________________________
                    b.  amount = 0

                     units = 150
                     if(units <= 100):

                         amount = 0
                     elif(units > 100 and units <= 200):
                         amount = (units-100) * 5
                     elif(units>200):
                         amount = 500 + (units - 200) * 10
                     print(amount)
                      ______________________________________________________________________________________

                    c.  a = 10
                     if(a > 6 and a <= 10):

                         print("Orange")
                     else:
                         print("Education")
                      ______________________________________________________________________________________







                                                                                        Control Structures in Python  107
   104   105   106   107   108   109   110   111   112   113   114