Page 183 - Information_Practice_Fliipbook_Class11
P. 183

10.  Write a program that asks the user to enter one’s name and age. Print out a message addressed to the user that tells the user the year
                  in which he/she will turn 100 years old.
             Ans.   from datetime import datetime
                  name = input('Enter Your Name:')
                  age = int(input('Enter your Age:'))
                  hundredYear = int((100 - age) + datetime.now().year)
                  print ('Hello %s.You will turn 100 years old in %s.' % (name,hundredYear))

              11.  Find the output of the following program segments:
                  a. for i in range(20,30,2):
                              print(i)
                  b. country = 'INDIA'
                      for i in country:
                            print (i)
                  c. i = 0; sum = 0
                     while i < 9:
                                  if i % 4 == 0:
                                  sum = sum + i
                                i = i + 2
                   print (sum)
             Ans.  a.  Output:
                    20
                    22
                    24
                    26
                    28
                  b.  Output:
                    I
                    N
                    D
                    I
                    A
                  c.  Output:
                    12

                                                     Case Study Based Question
                  Schools use “Student Management Information System” (SMIS) to manage student related data. This system provides facilities for:

                                                          Name of School


                                               Student Name: PQR      Roll No: 99
                                               Class: XI              Section: A
                                               Address:   Address Line 1
                                                         Address Line 2



                                               City:  ABC           Pin Code: 999999
                                               Parent's/ Guardian's Contact No: 9999999999





                                                                                              Looping in Python  169
   178   179   180   181   182   183   184   185   186   187   188