Page 122 - Touchpad_Plus_V3.2_Class 7
P. 122

print("x is less than or equal to 10")
                       else:

                           print("No conditions are true")
                        .....................................................................................................................................................................................................

                        .....................................................................................................................................................................................................

                     2.   Abhi has written the following code to check whether the number is divisible by 4 and 5. But he is
                        getting an error. What could be the possible reason?
                        number = int(input("Enter a number: "))
                       if (number % 4 = 0 and number % 5 = 0):
                           print(number, "is divisible by both 4 and 5.")

                       elif (number % 4 = 0):
                           print(number, "is divisible by 4 but not by 5.")
                       elif (number % 5 = 0):

                           print(number, "is divisible by 5 but not by 4.")
                       else:
                           print(number, "is neither divisible by 4 nor by 5.")

                        .....................................................................................................................................................................................................
                        .....................................................................................................................................................................................................

                  D.  Long answer type questions.
                     1.  Write the syntax of the if…else statement.

                        .....................................................................................................................................................................................................

                        .....................................................................................................................................................................................................

                        .....................................................................................................................................................................................................

                     2.   Meenakshi has written a code in which a conditional expression always returns True. Which block
                        of statements is executed if she has used an if…else statement?
                        .....................................................................................................................................................................................................

                        .....................................................................................................................................................................................................

                        .....................................................................................................................................................................................................

                  E.  Write the output of the following codes:

                     1. number = 0

                       if (number > 0):

                           print('Positive')

                       elif (number < 0):
                           print('Negative')


               120      Plus (Ver. 3.2)-VII
   117   118   119   120   121   122   123   124   125   126   127