Page 2 - Home Assignment - ITERATIVE STATEMENT
P. 2

f)  var = 7
                       while var > 0:
                          print ('Current variable value: ', var)
                          var = var -1
                          if var == 3:
                              break
                          else:
                              if var == 6:
                                 var = var -1
                                 continue
                       print ("Good bye!")

                   g)  M  = 4
                       for i in range(1,M+1):
                             for j in range(i+1):
                                   print(j+1,end=" ")
                            print("\n")

               7.  Write a program that takes the name and age of the user as input and displays a message
                   whether the user is eligible to apply for a driving license or not. (the eligible age is 18 years).

               8.  Write a program to generate the sequence: –5, 10, –15, 20, –25….. upto n, where n is an integer
                   input by the user.

                                                                     3
               9.  Write a program to find the sum of 1+ 1/8 + 1/27......1/n , where n is the number input by the
                   user.

               10. Write a program to find the sum of digits of an integer number, input by the user.

               11. Write a program to input a binary number and find and print its equivalent decimal.

               12. Write a program to find all the primes within a range, take lower and upper range input from
                   user.

               13. Write a program to find all the perfect numbers within a range, take lower and upper range
                   input from user.

               14. Write a program to print the following pattern:

                     A              1            A                   1
                     BC             12           AB                  21
                     DEF            123          ABC                 321
                     GHIJ           1234         ABCD                4321
                     KLMN           12345        ABCDE               54321
                     OPQRS                       …
                                                 all 26 lines
   1   2