Page 72 - Code & Click - 8
P. 72
2. The counter variable gets updated automatically in the _________ loop.
3. The _________ in the Range( ) function is compulsory.
C. Write ‘T’ for True and ‘F’ for False statement.
1. The break statement restarts the loop. _______
2. The While loop gets executed a specified number of times. _______
3. The range( ) function can be used to generate a list of numbers. _______
D. Answer the following questions.
1. What are Iterative statements?
2. What is the difference between For and While loop in Python?
3. What are Jump statements? Explain the jump statements available in Python.
Computational Skills
Mind Stretching
1. Identify and underline the errors in the code given below. Also, write the correct code.
(a) # Program to display all numbers between 1 and 10 in decreasing order.
for num in range(1, 10, -1):
print(num)
(b) # Program to print the sum of numbers from 1 to 20.
sum = 1
num = 1
while num < 20:
sum = sum + num
print(“The sum of numbers from 1 to 20 = ” sum)
2. Write the output of the following code segments in Python:
(a) for count in range(2, 10):
print(count)
(b) prod = 1
num = 10
while X >= 1:
prod = prod * num
num = num – 1
print(prod)
Lab Work Computational Skills
Write the following in Python:
(a) Program to display the sequence 5, 8, 11, 14, … up to 76.
(b) Program to accept two numbers from the user and display all even numbers between the two
numbers in decreasing order.
(c) Program to calculate and display the sum of first 10 multiples of 3.
(d) Program to accept three numbers from the user and display all even numbers between the smallest
and largest numbers, excluding the multiples of the third number.
70