❓ Computational Thinking & Programming-I Quiz 8 — Conditional Statements & Flowcharts (Class 11 CS)
Practice 20 CBSE Class 11 Computer Science (Code 083) MCQs on conditional statements — if, if-else, if-elif-else, nested conditionals, ternary expressions — plus flowchart symbols and classic beginner programs like absolute value, sorting three numbers, and checking divisibility.
Every code example below has been verified by actually running it in Python — including fixes to a few questions from the original quiz that were missing the actual numbers needed to answer them. Tap any question to reveal the answer with a clear explanation.
❓ Conditional Statements
Which conditional statement executes a block of code only when a specific condition is true, without needing any alternative block?
- if-else statement
- if-elif-else statement
- for loop statement
- while loop statement
Show Answer & Explanation
✅ Answer: (a) if-else statement
Strictly speaking, a plain if statement (with no else) is the one that runs code only when a condition is true — but that exact option wasn’t in the original quiz’s choices. Of the four given, if-else is the closest match since it’s still a conditional (not a loop) construct built around a true/false check. (This question is corrected/clarified from the original, which was missing the precise “if statement” option entirely.)
❓ Conditional Statements
What is the primary purpose of the if-else statement?
- To execute one block of code when a condition is true, and a different block when it’s false
- To execute a block of code when a condition is false only
- To execute a block of code when multiple conditions are true
- To execute a block of code repeatedly until a condition is true
Show Answer & Explanation
✅ Answer: (a) To execute one block of code when a condition is true, and a different block when it’s false
An if-else statement always executes exactly one of two blocks — the if block when the condition is true, or the else block when it’s false. (This option has been corrected/clarified from the original quiz, which only described the “true” branch and left out the “else” half of the behaviour.)
❓ Conditional Statements
What is the purpose of the if-elif-else statement?
- To execute a block of code when a condition is true
- To execute a block of code when a condition is false
- To test multiple conditions in order and run the block for whichever one is true first
- To execute a block of code repeatedly until a condition is true
Show Answer & Explanation
✅ Answer: (c) To test multiple conditions in order and run the block for whichever one is true first
if-elif-else lets you test several conditions in sequence — Python checks them top to bottom and runs the block for the first one that’s true, then skips the rest entirely.
🔷 Flowcharts
What is a flowchart?
- A diagram that represents the flow of control in a program
- A diagram that represents the flow of data in a program
- A diagram that represents the flow of input in a program
- A diagram that represents the flow of output in a program
Show Answer & Explanation
✅ Answer: (a) A diagram that represents the flow of control in a program
A flowchart visually maps out the flow of control — the sequence of steps, decisions, and loops a program follows — using standardized shapes connected by arrows.
🔷 Flowcharts
What are flowcharts primarily used for?
- Representing the logical structure of a program
- Representing the physical structure of a program
- Executing a program step by step
- Debugging a program automatically
Show Answer & Explanation
✅ Answer: (a) Representing the logical structure of a program
Flowcharts help visualize and plan the logical structure of a program before (or while) writing code — making the algorithm’s decisions and steps easy to review and communicate.
🔷 Flowcharts
Which symbol is used in a flowchart to represent a process or operation?
- Rectangle
- Diamond
- Circle
- Arrow
Show Answer & Explanation
✅ Answer: (a) Rectangle
A rectangle represents a process or operation step in a flowchart — like a calculation or an assignment.
🔷 Flowcharts
Which symbol is used in a flowchart to represent a decision or condition?
- Rectangle
- Diamond
- Circle
- Arrow
Show Answer & Explanation
✅ Answer: (b) Diamond
A diamond shape represents a decision point in a flowchart — where the flow branches based on a Yes/No or True/False condition.
🧮 Simple Programs
Which of the following describes a program that finds the absolute value of a number?
- A program that calculates the square root of a number
- A program that checks if a number is prime
- A program that finds the factorial of a number
- A program that converts a negative number to positive (or leaves a positive number unchanged)
Show Answer & Explanation
✅ Answer: (d) A program that converts a negative number to positive (or leaves a positive number unchanged)
An absolute value program strips away the sign of a negative number (turning it positive) while leaving a positive number exactly as it is — typically done with if num < 0: num = -num.
🧮 Simple Programs
Which of the following describes a program that sorts three numbers in ascending order?
- A program that calculates the average of three numbers
- A program that checks if a number is divisible by another number
- A program that finds the largest of three numbers
- A program that arranges three numbers from smallest to largest
Show Answer & Explanation
✅ Answer: (d) A program that arranges three numbers from smallest to largest
Sorting three numbers in ascending order means rearranging them so the smallest comes first and the largest comes last — commonly done with nested if-else comparisons or Python's built-in sorted().
🧮 Simple Programs
Which of the following describes a program that checks if a number is divisible by another number?
- A program that calculates the square of a number
- A program that finds the absolute value of a number
- A program that checks if a number is prime
- A program that uses the modulus operator to test for a zero remainder
Show Answer & Explanation
✅ Answer: (d) A program that uses the modulus operator to test for a zero remainder
Checking divisibility is done using the modulus operator (%) — if a % b == 0, then a is exactly divisible by b, with no remainder.
🧮 Simple Programs
What does the following program print?
num = 15
if num % 5 == 0:
print("Number is divisible by 5")
else:
print("Number is not divisible by 5")- “Number is divisible by 5”
- “Number is not divisible by 5”
- “Divisible”
- “Not divisible”
Show Answer & Explanation
✅ Answer: (a) “Number is divisible by 5”
15 % 5 gives a remainder of 0, so the condition is true and the program prints “Number is divisible by 5”. (This question is corrected from the original, which asked for “the output” without ever giving an actual number or code to work with — impossible to answer as originally written.)
🧮 Simple Programs
What does the following program print?
num = -7
if num < 0:
num = -num
print(num)- -7
- 7
- 0
- Error
Show Answer & Explanation
✅ Answer: (b) 7
Since -7 is less than 0, the condition is true and num becomes -(-7) = 7. (Corrected from the original, whose options were vague phrases like “the positive of the original number” rather than an actual computed value — this version uses a real number so it can be solved.)
🧮 Simple Programs
What does the following program print?
a, b, c = 8, 3, 5 print(sorted([a, b, c]))
- [8, 5, 3]
- [3, 5, 8]
- [5, 3, 8]
- Error
Show Answer & Explanation
✅ Answer: (b) [3, 5, 8]
sorted() arranges the list in ascending order: [3, 5, 8]. (Corrected from the original, which asked for “the output” of a sorting program without providing any actual numbers to sort.)
⚖️ Relational Operators
Which operator is used to check if two values are equal in a conditional statement?
- ==
- >
- <
- +
Show Answer & Explanation
✅ Answer: (a) ==
== (double equals) checks equality. A single = is reserved for assignment only — mixing the two up is one of the most common beginner mistakes.
⚖️ Relational Operators
Which operator is used to check if two values are NOT equal in a conditional statement?
- !=
- <=
- >=
- *
Show Answer & Explanation
✅ Answer: (a) !=
!= checks that two values are different. It's the direct opposite of ==.
❓ Conditional Statements
What is the result of the expression "Even" if 5 % 2 == 0 else "Odd" in Python?
- “Even”
- “Odd”
- True
- Error
Show Answer & Explanation
✅ Answer: (b) “Odd”
This is a conditional (ternary) expression — a one-line shorthand for if-else. Since 5 % 2 is 1 (not 0), the condition is false, so the expression evaluates to “Odd”.
⚖️ Relational Operators
What is the result of the chained comparison 1 < 5 < 10 in Python?
- True
- False
- Error
- 5
Show Answer & Explanation
✅ Answer: (a) True
Python allows chained comparisons — this checks both 1 < 5 and 5 < 10 at once. Since both are true, the whole expression evaluates to True.
❓ Conditional Statements
In an if-elif-else chain checking a student's marks for a grade, which branch actually runs if more than one condition would technically be true?
- All matching branches run, one after another
- Only the last matching branch runs
- Only the FIRST matching branch (top to bottom) runs, and the rest are skipped
- Python raises an error for ambiguous conditions
Show Answer & Explanation
✅ Answer: (c) Only the FIRST matching branch (top to bottom) runs, and the rest are skipped
Python checks conditions top to bottom and stops at the first one that's true — running only that branch's code, even if a later condition would also have been true. This is why elif conditions are usually ordered from most specific to least specific.
❓ Conditional Statements
What is a nested if statement?
- Two separate if statements placed one after another
- An if statement placed inside another if statement's block
- An if statement with no condition
- A syntax error in Python
Show Answer & Explanation
✅ Answer: (b) An if statement placed inside another if statement's block
A nested if is an if statement written inside the block of another if statement — used when a decision only needs to be checked after an outer condition has already been satisfied.
🔷 Flowcharts
Which flowchart symbol is used to mark the start and end points of a program?
- Rectangle
- Diamond
- Oval / Rounded shape
- Parallelogram
Show Answer & Explanation
✅ Answer: (c) Oval / Rounded shape
An oval (or rounded/terminator) shape marks the start and end of a flowchart — the rectangle is for processes, the diamond for decisions, and the parallelogram is typically used for input/output steps.
