Class 11 Computer Science Chapter 6 Question Bank CBSE Board Pattern

Section A — MCQs (10 questions, 1 mark each)

Q1. Which of the following control structures is used for decision making in Python?
(a) for loop
(b) if statement
(c) while loop
(d) range() function

Q2. In Python, the statements inside an if block are identified by:
(a) curly braces
(b) indentation
(c) parentheses
(d) colon only

Q3. What will be the output of the following code?
python num = 5 if num > 10: print("Greater") else: print("Smaller or equal") (a) Greater
(b) Smaller or equal
(c) No output
(d) Error

Q4. The range(5) function generates which sequence?
(a) 1 2 3 4 5
(b) 0 1 2 3 4
(c) 0 1 2 3 4 5
(d) 5 4 3 2 1

Q5. Which statement is used to terminate the current loop immediately?
(a) continue
(b) break
(c) pass
(d) exit

Q6. Assertion (A): The while loop may execute zero times if the condition is initially false.
Reason (R): The condition of the while loop is checked before the body executes.

Which of the following is correct?
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false.
(d) A is false but R is true.

Q7. Assertion (A): Nested if statements are allowed inside elif blocks in Python.
Reason (R): Python supports multiple levels of nesting for selection statements.

Which of the following is correct?
(a) Both A and R are true and R is the correct explanation of A.
(b) Both A and R are true but R is not the correct explanation of A.
(c) A is true but R is false.
(d) A is false but R is true.

Q8. The continue statement inside a loop:
(a) terminates the loop
(b) skips the remaining statements of the current iteration
(c) restarts the program
(d) prints the current value

Q9. Which loop is preferred when the number of iterations is known in advance?
(a) while loop
(b) for loop
(c) nested loop
(d) if statement

Q10. In the statement for letter in 'PYTHON':, how many times will the loop body execute?
(a) 5
(b) 6
(c) 7
(d) 0

Section B — Very Short Answer (6 questions, 2 marks each)

Q1. Define the term “flow of control” as mentioned in the chapter.
Q2. Differentiate between break and continue statements (one point each).
Q3. What is the purpose of the range() function? Give its general syntax.
Q4. Write the output of the following code fragment:
python for num in range(2, 10, 2): print(num)
Q5. What is indentation in Python? Why is it important in control structures?
Q6. State the condition under which a while loop becomes an infinite loop.

Section C — Short Answer (5 questions, 3 marks each)

Q1. Rewrite the following code using if-elif-else to check whether a number is positive, negative or zero (as shown in Example 6.2).
python number = int(input("Enter a number: ")) if number > 0: print("Number is positive") if number < 0: print("Number is negative") if number == 0: print("Number is zero")

Q2. Find the error(s) in the following code and correct it (refer to indentation rules given in the chapter):
python num1 = 5 num2 = 6 if num1 > num2: print("first number is larger") print("Bye") else: print("second number is larger") print("Bye Bye")

Q3. Write the output of the following code and explain why:
python count = 1 while count <= 5: print(count) count += 1

Q4. What will be the output of the following nested loop?
python for var1 in range(2): print("Outer", var1) for var2 in range(3): print(var2)

Q5. Explain the working of the break statement with reference to Program 6-12.

Section D — Long Answer (3 questions, 5 marks each)

Q1. Write a complete Python program to print the positive difference of two numbers entered by the user (as shown in Program 6-2). Use proper indentation and if-else.

Q2. Draw a trace table (dry run) for the following code and show the values of variables after each iteration:
python num = 6 factor = 2 print(1, end=' ') while factor <= num/2: if num % factor == 0: print(factor, end=' ') factor += 1 print(num)

Q3. Write a complete Python program that accepts a number from the user and prints whether it is a prime number or not using a for loop and break statement (as demonstrated in Program 6-14).

Section E — Case/Source-Based (2 questions, 4 marks each)

Case 1

A school wants to automate the process of checking eligibility of students for a scholarship. The program must accept the percentage of marks and display the appropriate message using selection statements.

Sub-questions:

(a) Which control structure will be most suitable for checking multiple percentage ranges?
(b) Write the if-elif-else structure that prints “Eligible for full scholarship” if percentage > 85, “Eligible for partial scholarship” if percentage is between 75 and 85, else “Not eligible”.
(c) What will happen if indentation is not used properly in the above structure?
(d) Modify the structure to also handle the case when percentage < 30 and display “Needs improvement”.

Case 2

A teacher wants to print the multiplication table of any number entered by the student using a loop.

Sub-questions:

(a) Which loop (for or while) is more suitable when the number of iterations (10) is known?
(b) Write a for loop using range() that prints the table of a number n from 1 to 10.
(c) How can the same task be achieved using a while loop?
(d) If the user enters a negative number for n, which statement can be used to stop taking further input?

Answer Key Attempt all questions first,
then tap to reveal

Section A

Q1. (b)
Q2. (b)
Q3. (b)
Q4. (b)
Q5. (b)
Q6. (a)
Q7. (a)
Q8. (b)
Q9. (b)
Q10. (b)

Section B

Q1. The order of execution of statements in a program is known as flow of control.
Q2. break terminates the loop; continue skips the current iteration.
Q3. range() generates a sequence of numbers. Syntax: range([start], stop[, step]).
Q4.
2 4 6 8
Q5. Leading whitespace at the beginning of a statement; it defines blocks of code.
Q6. When the loop condition never becomes false.

Section C

Q1. Correct code uses if-elif-else (as in Example 6.2).
Q2. Indentation error; statements under if and else must be indented uniformly.
Q3. Prints 1 to 5 (one per line) because count is incremented until condition becomes false.
Q4. Outer loop runs twice; inner loop prints 0 1 2 each time.
Q5. When num == 8, break terminates the loop and control moves outside.

Section D

Q1.
python num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) if num1 > num2: diff = num1 - num2 else: diff = num2 - num1 print("The difference of", num1, "and", num2, "is", diff)
Q2. Trace table shows factors 1 2 3 6 (step-by-step execution of while loop).
Q3. Complete prime-checking program using for loop and break (as in Program 6-14).

Section E

Case 1: (a) if-elif-else (b) correct chained conditions (c) IndentationError / logical error (d) extra elif for < 30.
Case 2: (a) for loop (b) for i in range(1,11): print(n*i) (c) while version (d) break.

All questions are answerable from the NCERT chapter text. Reviewed by GFIS faculty.