Page 55 - PYTHON-11
P. 55

(b)  Python has one special  data type called  None. It is  used to indicate  something  that has not  yet  been
                   created. It is a non-NULL, unidentified value.
            28.  (a)  Write a Python program to accept a number and display whether the number is palindrome or not.   [2]
                                                           Or
                (b)  Write a Python program to accept a number and find out whether it is a perfect number or not.
          Ans.   (a)  num= int(input("enter a number"))
                   temp =num
                   rev =0

                   while temp > 0:
                        digit = temp % 10
                        rev = rev*10 + digit
                        temp = int(temp/10)
                   if num == rev:
                        print("It is a palindrome")
                   else:
                        print("It is not a palindrome")
                                                           Or
                (b)  i=1

                   s=0
                   num = int(input("enter a number"))
                   while i<num:
                        if num%i ==0:
                        s+=i
                        i = i+1
                   if s == num:
                        print("it is a perfect number")
                   else:
                        print("it is not a perfect number")
                                                 Section C (3 × 3 = 9 Marks)
            29.  (a)  Write a Python program to find and display the sum of all the values which are ending with 3 from a list.
                                                                                                            [3]
                                                           Or
                (b)  Write a Python program to find the number of occurrences of each vowel present in the inputted string
                   using dictionary.

           Ans.  (a)  l=[97,43,55,63,3,45,343,33]
                   sum = 0
                   x = len(l)
                   for i in range(0, x):
                        if type(l[i]) == int:
                               if l[i]%10 == 3:
                                      sum+=l[i]
                        print(sum)
                                                           Or






                                                           M.4
   50   51   52   53   54   55   56   57   58   59   60