You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p><strong>Kya karta hai:</strong> Yeh condition ko check karta hai aur agar condition true hoti hai, to block of code execute hota hai.</p>
<divclass="rule"><strong>Rule:</strong> Condition ko sahi likhna zaroori hai, agar galat likha to statement execute nahi hoga.</div>
<divclass="code-block">
# if statement example
age = 20
if age >= 18:
print("You are an adult.")
</div>
<divclass="output-block">
You are an adult.
</div>
<divclass="wrong-block">
# if statement example with wrong condition
age = 15
if age >= 18:
print("You are an adult.")
else:
print("You are not an adult.")
</div>
<divclass="output-block">
You are not an adult.
</div>
</div>
<divclass="section">
<h2>2. else Statement</h2>
<p><strong>Kya karta hai:</strong> Yeh default block hota hai jo else ke baad likha jata hai, jab condition false hoti hai.</p>
<divclass="rule"><strong>Rule:</strong> Else statement ko tabhi use karo jab condition fail ho jaaye.</div>
<divclass="code-block">
# else statement example
age = 15
if age >= 18:
print("You are an adult.")
else:
print("You are not an adult.")
</div>
<divclass="output-block">
You are not an adult.
</div>
</div>
<divclass="section">
<h2>3. elif Statement</h2>
<p><strong>Kya karta hai:</strong> Yeh else aur if ka combination hota hai. Jab ek se zyada conditions check karni hoti hain to elif ka use hota hai.</p>
<divclass="rule"><strong>Rule:</strong> elif ko tab use karo jab ek hi time pe multiple conditions check karni ho.</div>
<divclass="code-block">
# elif statement example
age = 25
if age <18:
print("You are a child.")
elif age < 30:
print("You are a young adult.")
else:
print("You are an adult.")
</div>
<divclass="output-block">
You are a young adult.
</div>
</div>
<divclass="section">
<h2>4. Nested Conditions</h2>
<p><strong>Kya karta hai:</strong> Jab ek condition ke andar doosri condition likhi jaati hai, to usse nested condition kehte hain.</p>
<divclass="rule"><strong>Rule:</strong> Nested conditions ko tab use karo jab complex decision making ho.</div>