TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun · 77.8K subscribers
Post #4434 4.49K
if age >= 18:
print("Eligible")


❌ Incorrect Indentation

if age >= 18:
print("Eligible")


Python requires proper indentation.

Correct:

if age >= 18:
print("Eligible")


🔹 11. Real-World Data Science Example

prediction = 0.82
if prediction >= 0.5:
print("Spam Email")
else:
print("Not Spam")


Many Machine Learning classification models use similar logic to convert prediction probabilities into categories.

🎯 Practice Questions

1. Check whether a number is positive or negative.

2. Check whether a person is eligible to vote.

3. Create a grading system using "if...elif...else".

4. Check whether a number is even or odd.

5. Determine the largest of three numbers.

🎯 Key Takeaways

✅ Use "if" to execute code when a condition is True.

✅ Use "else" to execute code when the condition is False.

✅ Use "elif" to check multiple conditions.

✅ Nested "if" statements allow more complex decision-making.

✅ Logical operators (and, or, not) help combine conditions.

✅ The ternary operator provides a concise way to write simple "if...else" statements.

Conditional statements are the foundation of decision-making in Python and are widely used in automation, data analysis, machine learning, and AI applications.

Double Tap ❤️ For Part-5
  • ❤ 14
  • 😁 1
  • 😢 1
More from @datasciencefun
  1. Oct 7, 2026ORDER BY salary DESC LIMIT 5; Mistake 3 — Forgetting that LIMIT applies after sorting For…
  2. Oct 7, 2026🚀 Data Science Roadmap 2026 📍 Phase 3: SQL for Data Science 📖 Topic 4 — LIMIT LIMIT is…
  3. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  4. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  5. Oct 2, 2026Data Visualisation tips for beginners
  6. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →