Teachers and Examiners (CBSESkillEduction) collaborated to create the Flow of Control in Python Class 11 Questions and Answers. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.
Flow of Control in Python Class 11 Questions and Answers
1. What is the difference between else and elif construct of if statement?
Answer – Elif allows checking multiple conditions; when the if statement is false, the program moves to elif condition. In other hand else executes only if all the conditions are false.
2. What is the purpose of range() function? Give one example.
Answer – Python comes with a built-in function called range(). It is used to generate a list of numbers from the specified start value to the specified stop value (excluding stop value). For the purpose of creating a number series, this is frequently used in for loops.
3. Differentiate between break and continue statements using examples.
Answer – Break and continue both have different work in Python. The break statement in Python terminates the loop when the condition is met. On the other hand, continue skipping the current iteration and move to the next statement.
Example of Break Statement:
for num in range(1, 11):
if num == 5:
break # Stops the loop when num is 5
print(num)
Output:
1
2
3
4
Example of Continue Statement:
for num in range(1, 11):
if num == 5:
continue # Skips the number 5 and moves to next iteration
print(num)
Output:
1
2
3
4
6
7
8
9
10
4. What is an infinite loop? Give one example.
Answer – The infinite loop occurs when the loop condition never becomes false; this causes the program to run forever. So, a loop that never ends is known as an infinite loop.
Example of infinite loop –
while True:
print("This is an infinite loop!")
In the above program, the condition True never changes; because of that, the loop will become infinite.
5. Find the output of the following program segments:
(i)
a = 110
while a > 100:
print(a)
a -= 2
Output:
110
108
106
104
102
for i in range(20, 30, 2):
print(i)
Output:
20
22
24
26
28
country = 'INDIA'
for i in country:
print(i)
Output:
I
N
D
I
A
i = 0
sum_value = 0
while i < 9:
if i % 4 == 0:
sum_value += i
i += 2
print(sum_value)
Output:
12
for x in range(1, 4):
for y in range(2, 5):
if x * y > 10:
break
print(x * y)
Output:
2
3
4
4
6
8
6
9
var = 7
while var > 0:
print("Current variable value:", var)
var -= 1
if var == 3:
break
else:
if var == 6:
var -= 1
continue
print("Good bye!")
Output:
Current variable value: 7
Current variable value: 5
Good bye!
Current variable value: 4
1. Write a program that takes the name and age of the user as input and displays a message whether the user is eligible to apply for a driving license or not.
(the eligible age is 18 years).
Answer –
name = input("Enter your name: ")
age = int(input("Enter your age: "))
if age >= 18:
print(f"Hello {name}, you are eligible to apply for a driving license.")
else:
print(f"Hello {name}, you are not eligible to apply for a driving license.")
Output:
Enter your name: Rajesh
Enter your age: 20
Hello Rajesh, you are eligible to apply for a driving license.
2. Write a function to print the table of a given number. The number has to be entered by the user.
Answer –
num = int(input("Enter the number for the table: "))
print(f"\nMultiplication Table of {num}:")
for i in range(1, 11):
print(f"{num} × {i} = {num * i}")
Output:
Enter the number for the table: 8
Multiplication Table of 8:
8 × 1 = 8
8 × 2 = 16
8 × 3 = 24
8 × 4 = 32
8 × 5 = 40
8 × 6 = 48
8 × 7 = 56
8 × 8 = 64
8 × 9 = 72
8 × 10 = 80
3. Write a program that prints minimum and maximum of five numbers entered by the user.
Answer –
min_val = None
max_val = None
# Loop to get 5 numbers from user
for a in range(5):
x = int(input("Enter the number: "))
if a == 0:
min_val = max_val = x
if x < min_val:
min_val = x
if x > max_val:
max_val = x
print("The largest number is", max_val)
print("The smallest number is", min_val)
Output:
Enter the number: 63
Enter the number: 21
Enter the number: 49
Enter the number: 75
Enter the number: 25
The largest number is 75
The smallest number is 21
4. Write a program to check if the year entered by the user is a leap year or not.
Answer –
year = int(input("Enter year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print(f"{year} is a leap year.")
else:
print(f"{year} is not a leap year.")
Output:
Enter year: 2000
2000 is a leap year.
Enter year: 2023
2023 is not a leap year.
Enter year: 2024
2024 is a leap year.
5. Write a program to generate the sequence: –5, 10, –15, 20, –25….. upto n, where n is an integer input by the user.
Answer –
num = int(input("Enter the number: "))
for a in range(1, num + 1):
if a % 2 == 0:
print(a * 5, end=", " if a < num else "")
else:
print(a * 5 * (-1), end=", " if a < num else "")
Output:
Enter the number: 12
-5, 10, -15, 20, -25, 30, -35, 40, -45, 50, -55, 60
6. Write a program to find the sum of 1+ 1/8 + 1/27……1/n3, where n is the number input by the user.
Answer –
sum_series = 0.0
n = int(input("Enter the number: "))
for a in range(1, n + 1):
sum_series += 1 / (a ** 3)
print("The sum of the series is:", round(sum_series, 2))
Output:
Enter the number: 10
The sum of the series is: 1.20
7. Write a program to find the sum of digits of an integer number, input by the user.
Answer –
n = int(input("Enter the number: "))
sum_digits = 0
while n > 0:
digit = n % 10
sum_digits =sum_digits + digit
n = n // 10
print("The sum of digits is:", sum_digits)
Output:
8. Write a function that checks whether an input number is a palindrome or not.
[Note: A number or a string is called palindrome if it appears same when written in reverse order also. For example, 12321 is a palindrome while 123421 is not a palindrome]
Answer –
num = int(input("Enter the number: "))
rev = 0
temp = num
while temp > 0:
digit = temp % 10
rev = (rev * 10) + digit
temp = temp // 10
if num == rev:
print("Palindrome")
else:
print("Not a Palindrome")
Output:
Enter the number: 121
Palindrome
Enter the number: 123
Not a Palindrome
9. Write a program to print the following patterns:

Answer –
n = 3
# Upper part of the diamond
for i in range(1, n + 1):
blank = " " * (n - i)
stars = "*" * (2 * i - 1)
print(blank + stars)
# Lower part of the diamond
for j in range(n - 1, 0, -1):
blank = " " * (n - j)
stars = "*" * (2 * j - 1)
print(blank + stars)
Output:
*
***
*****
***
*
n = 5
for i in range(1, n + 1):
blank = " " * (n - i)
print(blank, end=" ")
for k in range(i, 1, -1):
print(k, end=" ")
for j in range(1, i + 1):
print(j, end=" ")
print()
Output:
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
n = 5
for i in range(n, 0, -1):
blank = " " * (n - i)
print(blank, end=" ")
for j in range(1, i + 1):
print(j, end=" ")
print()
Output:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
10. Write a program to find the grade of a student when grades are allocated as given in the table below.
Percentage of Marks Grade
Above 90% – A
80% to 90% – B
70% to 80% – C
60% to 70% – D
Below 60% – E
Percentage of the marks obtained by the student is input to the program.
Answer –
percentage = float(input("Enter the percentage of marks: "))
if percentage > 90:
grade = "A"
elif percentage > 80:
grade = "B"
elif percentage > 70:
grade = "C"
elif percentage >= 60:
grade = "D"
else:
grade = "E"
print(f"Your grade is: {grade}")
Output:
Enter the percentage of marks: 99
Your grade is: A
Computer Science Class 11 Questions and Answers
- Computer Systems and Organisation
- Introduction to problem solving
- Getting Started with Python
- Flow of Control statements in Python
- String in Python
- Lists in Python
- Tuples and Dictionary in Python
- Society, Law and Ethics
Disclaimer: We have taken an effort to provide you with the accurate handout of “Flow of Control in Python Class 11 Questions and Answers“. If you feel that there is any error or mistake, please contact me at anuraganand2017@gmail.com. The above CBSE study material present on our websites is for education purpose, not our copyrights. All the above content and Screenshot are taken from Computer Science Class 11 NCERT Textbook and CBSE Support Material which is present in CBSEACADEMIC website, This Textbook and Support Material are legally copyright by Central Board of Secondary Education. We are only providing a medium and helping the students to improve the performances in the examination.
Images and content shown above are the property of individual organizations and are used here for reference purposes only.
For more information, refer to the official CBSE textbooks available at cbseacademic.nic.in