Conditional Statements in Python TRB CSI › Python Programming › conditional statements

Conditional Statements in Python

A conditional statement is used to execute a block of code based on whether a given condition is True or False. தமிழில்: கொடுக்கப்பட்ட condition உண்மையா (True) அல்லது பொய்யா (False) என்பதை check செய்து, அதற்கு ஏற்ற code-ஐ execute செய்வது C…

Premium — locked Intermediate 20 min 180 cards 33 programs 8 MCQs v3
This is a premium lesson. You can see the shape of every card — unlock to read them. Unlock

Conditional Statements in Python Conditional Statements என்பது ஒரு condition True அல்லது False என்பதைப் பொறுத……

Premium This card is part of the premium lesson. Unlock
Definition

A conditional statement is used to execute a block of code based on whether a given condition is True o……

Premium This card is part of the premium lesson. Unlock
Simple Explanation

Real-time example: ஒரு student mark: Mark = 70 Condition: Mark ……

Premium This card is part of the premium lesson. Unlock
Flow

Basic conditional flow: Condition ↓ True / False ↙ ↘ True False ↓ ↓ ……

Premium This card is part of the premium lesson. Unlock
Explanation
Python conditional statements

1. if 2. if...else 3. if...el……

Premium This card is part of the premium lesson. Unlock
List

1. if Statement…

Premium This card is part of the premium lesson. Unlock
Explanation

கவனிக்க: if condition : inden……

Premium This card is part of the premium lesson. Unlock
List

1. IF STATEMENT…

Premium This card is part of the premium lesson. Unlock
Definition

Condition True ஆக இருந்தால் மட……

Premium This card is part of the premium lesson. Unlock
Explanation

age = 20 age variable-ல் 20 store செய்கிறோம். if age >= 18: ……

Premium This card is part of the premium lesson. Unlock
Explanation
False condition

age = 15 if age >= 18: print(……

Premium This card is part of the premium lesson. Unlock
Output
Result

ஏனெனில் if block skip செய்யப்……

Premium This card is part of the premium lesson. Unlock
Algorithm

1. IF...ELSE STATEMENT…

Premium This card is part of the premium lesson. Unlock
Definition

Condition True என்றால் ஒரு block; Fal……

Premium This card is part of the premium lesson. Unlock
Important

else-க்கு condition எழுதக்கூட……

Premium This card is part of the premium lesson. Unlock
Program
Program - even or odd
Explanation

num % 2 means remainder. For: 10 % 2……

Premium This card is part of the premium lesson. Unlock
Definition

Multiple conditions check செய்ய elif பயன்படும்.……

Premium This card is part of the premium lesson. Unlock
Output
Result

Next: 75 >= 60…

Premium This card is part of the premium lesson. Unlock
Output
Result

Therefore: Grade B Once condition True ……

Premium This card is part of the premium lesson. Unlock
Important
Very important

Consider: mark = 95 if mark >= 4……

Premium This card is part of the premium lesson. Unlock

Why not Excellent? Because first condition: 95 >= 40 alre……

Premium This card is part of the premium lesson. Unlock
Memory Trick

Multiple ranges check செய்யும……

Premium This card is part of the premium lesson. Unlock
Program
Example

= 90 = 80 = 70 = 40…

Premium This card is part of the premium lesson. Unlock
Explanation

else…

Premium This card is part of the premium lesson. Unlock
Program
Grade program
Algorithm

1. NESTED IF…

Premium This card is part of the premium lesson. Unlock
Definition

ஒரு if statement-க்கு உள்ளே மற்றொரு if statem……

Premium This card is part of the premium lesson. Unlock
Flow

age >= 18 ? ↓ True ↓ has_id ?……

Premium This card is part of the premium lesson. Unlock
Explanation
Nested if else

age = 20 has_id = False if age >= 18: if has_id: ……

Premium This card is part of the premium lesson. Unlock
Explanation

First: 20 >= 18 True. So inner if check: ……

Premium This card is part of the premium lesson. Unlock
Comparison
if vs if...else
Comparison
if vs elif
Comparison

elif vs Nested if elif Multiple alternative conditions: if mark >= 90: print("A") elif m……

Premium This card is part of the premium lesson. Unlock
Explanation
Indentation

Python conditional statements-ல் indentation மிகவும் முக்கியம்.……

Premium This card is part of the premium lesson. Unlock
Important

Python-ல் C/C++ மாதிரி { } curly braces block define செய்ய தேவையில்……

Premium This card is part of the premium lesson. Unlock
Explanation
Colon

Conditional statement முடிவில் : ……

Premium This card is part of the premium lesson. Unlock
Explanation
Boolean condition

if internally condition-ஐ Boolean……

Premium This card is part of the premium lesson. Unlock
Program
But
Explanation
Truthy falsy

Python: if 10: print("Yes")…

Premium This card is part of the premium lesson. Unlock

Because non-zero number is Tr……

Premium This card is part of the premium lesson. Unlock

Because: 0 = Falsy…

Premium This card is part of the premium lesson. Unlock
Explanation
Logical operators with if

Conditions-ஐ combine செய்ய: and or not பயன்படுத்தலாம். AND Example age = 25 citizen = True if age ……

Premium This card is part of the premium lesson. Unlock
Explanation
Short hand if

Python supports single-line i……

Premium This card is part of the premium lesson. Unlock
Explanation
Conditional expression

Python supports conditional expre……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

result = "Adult" if age >= 18……

Premium This card is part of the premium lesson. Unlock

இதனை பொதுவாக ternary conditio……

Premium This card is part of the premium lesson. Unlock
Important

Python-ல் C/C++ style: condition ? value……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 1

= instead of == Wrong: if x = 1……

Premium This card is part of the premium lesson. Unlock
Remember

= → Assignment == → Comparison…

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 2

Missing colon Wrong: if x > 1……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 3

Incorrect indentation Wrong: if ……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 4

elseif Wrong: elseif x > 5: C……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 5

Semicolon unnecessary Python: i……

Premium This card is part of the premium lesson. Unlock
Common Mistake
Error 6

Wrong condition order Wrong: mark = 9……

Premium This card is part of the premium lesson. Unlock
Program
Correct
Memory Trick

Conditional statements: IF → If this is true, do it ELSE → Otherwise do this ELIF → O……

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Python decision-making key……

Premium This card is part of the premium lesson. Unlock
TRB Point

if…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Multiple conditions?…

Premium This card is part of the premium lesson. Unlock
TRB Point

elif…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. False/default block?…

Premium This card is part of the premium lesson. Unlock
TRB Point

else…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Python uses block structur……

Premium This card is part of the premium lesson. Unlock
TRB Point

Indentation…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Does Python require curly ……

Premium This card is part of the premium lesson. Unlock
TRB Point

No…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. elif means?…

Premium This card is part of the premium lesson. Unlock
TRB Point

else if…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. else requires condition?…

Premium This card is part of the premium lesson. Unlock
TRB Point

No…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Which symbol follows an if……

Premium This card is part of the premium lesson. Unlock
TRB Point

:…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Can if exist without else?…

Premium This card is part of the premium lesson. Unlock
TRB Point

Yes…

Premium This card is part of the premium lesson. Unlock
TRB Point

1. Can multiple elif blocks e……

Premium This card is part of the premium lesson. Unlock
TRB Point

Yes…

Premium This card is part of the premium lesson. Unlock
Interview Point

Question: What are conditional statements in Python? Conditional statements control program flow by executing……

Premium This card is part of the premium lesson. Unlock
Program
Example
Explanation

Both print statements belong to the if blo……

Premium This card is part of the premium lesson. Unlock
Explanation

Both conditions independently……

Premium This card is part of the premium lesson. Unlock
Program
But

Multiple if statements = indep……

Premium This card is part of the premium lesson. Unlock
MCQ

Which keyword starts a condit……

Premium This card is part of the premium lesson. Unlock
MCQ

Which keyword means "else if"……

Premium This card is part of the premium lesson. Unlock
MCQ

What defines code blocks in P……

Premium This card is part of the premium lesson. Unlock
MCQ

What is the output? x = 10 if……

Premium This card is part of the premium lesson. Unlock
Algorithm

1. Which is correct syntax?…

Premium This card is part of the premium lesson. Unlock

A. if x > 5 B.…

Premium This card is part of the premium lesson. Unlock

if x > 5 { Answer: B…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. Can if be used without els……

Premium This card is part of the premium lesson. Unlock

Answer: A…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. What is nested if?…

Premium This card is part of the premium lesson. Unlock

Answer: C…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. What is the output?…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. Which operator is commonly……

Premium This card is part of the premium lesson. Unlock

Answer: B…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. What happens when an if co……

Premium This card is part of the premium lesson. Unlock

Answer: C…

Premium This card is part of the premium lesson. Unlock
Algorithm

1. What is the output?…

Premium This card is part of the premium lesson. Unlock
Practice
Practice 1

Positive or Negative Write a program: n……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 2

Even or Odd num = 7 if num % ……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 3

Largest of Two Numbers a = 20 b = 10 ……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 4

Pass or Fail mark = 35 if mar……

Premium This card is part of the premium lesson. Unlock
Practice
Practice 5

Voting Eligibility age = 19 if ag……

Premium This card is part of the premium lesson. Unlock
Summary

Python Conditional Statements: Conditional Statements │ ├── if │ ↓ │ One condition │ ├── if...else │ ↓ │ Two-……

Premium This card is part of the premium lesson. Unlock
Remember

if → Condition check elif → Another condition e……

Premium This card is part of the premium lesson. Unlock
Explanation
Short description

Conditional statements என்பது Python program-ன் decision-making mechanism. ஒரு condition True அல்லது False என……

Premium This card is part of the premium lesson. Unlock
Text size
17px
Theme
Contents
Print / PDF
Program