Page 109 - trackpad v5.1 class 8 flipbook
P. 109

d.  n = 7

                      factorial = 1
                      for i in range(1, n + 1):
                          factorial *= i
                      print("Factorial of", n, "is", factorial)
                        ______________________________________________________________________________

                                                                                              21 st
                 6.  Competency-based/Application-based questions.                          Century   #Critical Thinking
                                                                                             Skills  #Information Literacy
                    a.   Manvi wants to write a statement which will cause the program to skip the rest of
                        the statement of the current block and move to the next iteration of the loop. Which
                        statement should she use for this?
                    b.   Priya  is  working  on  a  program  where she  needs  to  check  multiple conditions sequentially and
                        execute corresponding statements for the first true condition. Which type of statements should she
                        use for this?







                      Video based question                                                                 Scan the

                      Watch the video and answer the question.                                             QR Code
                         In which condition we use for and while loops?








                                                                                              21 st   #Critical Thinking
                     LAB ACTIVITY                                                           Century   #Technology Literacy
                                                                                             Skills

                     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 using a 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

                     ▶     Write a Python program to display the sum of even and odd numbers separately within a given
                         range of 1 to 50.









                                                                                        Control Structures in Python  107
   104   105   106   107   108   109   110   111   112   113   114