Lesson 06 � Logic

CODE KO
DECISION DO.

Real program har input par same response nahi deta. User logged in ho to dashboard, nahi ho to sign-in. Score pass ho to certificate. Isi branching ko if, elif aur else

? 20 min✓ BeginnerPrerequisite: Variables

WHY: business rules ko code mein badalna

Condition ek expression hai jo True ya False banata hai. Python true branch ko run karega, false case mein next branch check karega.

python
score = 76

if score >= 90:
 print("Excellent")
elif score >= 60:
 print("Pass")
else:
 print("Practice more")
IF

Sabse pehle rule ko test karta hai.

ELIF

Pehla rule false ho to alternate rule test karta hai.

ELSE

Koi condition match na ho to fallback path.

Comparison ko correct padho

== equality compare karta hai; = value assign karta hai. >=, <=, != bhi commonly use hote hain. Conditions ko top-to-bottom order mein likho: more specific cases pehle aate hain.

Try it: learner statusScore badal kar har branch check karo
Run Python dabayein

Multiple rules: and / or / not

and tab true hai jab dono conditions true hain. or mein ek true condition kaafi hai. Parentheses use karo jab intent clear karna ho; readable condition clever short condition se better hai.

Quick check

score variable pass hai ya nahi check karne wali condition likho. Pass mark 60 hai.

Greater-than-or-equal operator chahiye, assignment operator nahi.

Common mistakes

Conditions clear?

Ab same logic ko multiple values ke liye repeat karna seekho.