Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 89 - 2612_Digimind
P. 89

    (ii)  for loop

                            ______________________________________________________________________________

                            ______________________________________________________________________________

                        e.  What are jump statements?

                            ______________________________________________________________________________

                            ______________________________________________________________________________

                            ______________________________________________________________________________

                     6.  Write the output of the given Python Code:
                        a.  for i in range(1, 6):

                              if i == 3:
                                  continue

                              print(i)
                        b.  for i in range(2, 10, 2):

                             print(i)
                        c.  x = 10

                         while x > 0:
                             print(x)

                             x -= 2

                        d. n = 7
                         factorial = 1

                         for i in range(1, n + 1):

                             factorial *= i
                         print("Factorial of", n, "is", factorial)

                                                                                                  21 st   #Critical Thinking
                     7.  Competency-based/Application-based questions.                         Century   #Technology Literacy
                                                                                                 Skills
                        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.   Vansh needs to print selected numbers from 2 to 20 by skipping every alternate number. Which
                            Python feature will he use?

                                                                                                    Iteration in Python  87

| 84 85 86 87 88 89 90 91 92 93 94 |