Page 119 - Trackpad_V1_Book 8_Flipbook
P. 119

b.   Sum1=0

                          n = int(input(“Please enter number”))
                          for i in range(1, n+1, 1):
                          sum1 += i
                          print(“\n”)
                          print(“Sum is: ”, sum1)
                          ____________________________________________________________________________
                     c.   num = 24894

                          count = 0
                          while num != 0:
                          num //=10

                          count+= 1
                          print(“Total digits are : ”, count)
                          ____________________________________________________________________________






                      Video based question                                                                 Scan the

                      Watch the video and answer the question.                                             QR Code

                         Which  statement is used in the for ( ) and while ( ) loops?









                     LAB ACTIVITY                                                                  Computational Thinking



                     Visit your computer lab and perform the following actions:
                     ▶      Write a program in Python to find whether a given number is divisible by 5 or not.

                     ▶    Write a program in Python to compute the factorial of a given number.

                     ▶    Write a program using while loop in Python to print the multiplication table of 25.
                     ▶      Write a program to enter the age of a person and find out whether he is retired or not. The age of

                          retirement is 60 years.
                     ▶      A school has the following rules for the grading system:

                          Below 20 – F      20 to 40 – E             40 to 60 - D
                          60 to 80 – C     80 to 90 – B              Above 90 - A

                          Write a program to enter the marks and print the corresponding grade in Python.






                                                                                        Control Structures in Python  117
   114   115   116   117   118   119   120   121   122   123   124