Page 69 - Computer - 7
P. 69

(b)  X = 56

                   if (X > 100):
                        print(“X is greater than 100”)

                   else:
                        print(“X is smaller than 100”)


                   if (X > 50):
                        print(“but X is greater than 50”)

                   else:
                        print(“and X is smaller than 50 also”)




             Lab Work                                                                              Computational Skills


              Write the following programs in Python:
                (a)  Program to accept an alphabet from the user and display whether it is a vowel or consonant.
                (b)  Program to accept a number from the user and display whether it is a multiple of 7 or not.
                (c)  Program to accept three numbers from the user. Display the product of the numbers with the message
                    whether the product is even or odd.
                (d)  Accept two numbers and an operator from the user (+, –, *, ) and display the corresponding result
                    of the operation.
                (e)  Program to accept the number of units of electricity consumed by a user in a month and calculate
                    and display his bill. The criteria used for the calculation of the bill are as follows:
                                     Number of units                      Cost per unit
                                         Upto 200                              ` 0

                                     From 201 to 300                           ` 5
                                     From 301 to 500                           ` 6
                                      501 and above                            ` 7
                (f)  Program to accept a number from the user and display the day of the week corresponding to the
                    number. (1 represents Monday, 2 represents Tuesday, and so on). Display an error message in case of
                    a number different from 1, 2, 3, 4, 5, 6, or 7.



            DISCUSS                                                                                Communication Skills
            DISCUSS
             Discuss with your classmates the situations where each of the different Conditional statements in Python will
             be suitable for use.



           TEACHER’S DESK
           TEACHER’S DESK
           Explain, with illustrations, to the students the use of different Conditional statements.




                                                                                                              67
   64   65   66   67   68   69   70   71   72   73   74