Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 110 - 2607_Trackpad_Pro_5.1_flipbook_C7
P. 110

    Write a program to:
                            a.   check whether the year input by the user is a leap year or not. (a year is a Leap year, if the year
                               is a multiple of 4 and isn’t a multiple of 100 or if the year is a multiple of 400).
                            b.   calculate the area of square or circle according to the given input by the user. If the input is 1,
                               then calculate area of square, else find the area of a circle. Ask the user to input the values for
                               square or circle, based on the input.
                            c.  find whether the given character is a vowel or not.
                               i
                            d.   nput three numbers from the user, then print ‘You Won’ if the sum of input numbers is greater
                               than 1000.

                              COding Zone       COding Zone    {}      =     COding Zone Computational Thinking
                                    {C ding z ne}
                                                                                                                 []
                                                                                                        COding Zone
                                                                              </>
                         Find errors in the code of the programs given below and correct them. Also write the output.
                         1.  l = 40
                           m = 100
                           if m > a :
                           print ("m is greater than l")
                         2.  a = input("Enter a number")
                           if(a%6==0)
                               print("Divisible by 6")
                           else:
                               print("Not divisible by 6")
                         3.  signal = input("What is a traffic signal? :")
                           if signal == "Red':
                               print("Stop")
                           elif signal == "Yellow":
                               print "Wait")
                           elif signal == "Green":
                               print("Go")
                           else
                               print("Unrecognized signal!")

                           CAREER HERE

                     People who are expert in Python may pursue their career as a Software Developer.

                       FOR THE TEACHER

                      Discussion of control statements should be done comparing the situation faced in daily lives. This would help students
                      understand the concept better.

                                                                                            Control Structures in Python  109

| 105 106 107 108 109 110 111 112 113 114 115 |