LEARN COMPLETE PYTHON IN 24 HOURS
🟦 Python Basics
🔹 1. Introduction to Python
1.1 What is Python and Why Learn It in 2025?
1.2 Who Uses Python Today?
1.3 Python vs Other Languages
1.4 How to Install Python
1.5 Setting Up VS Code
🔹 2. Basic Building Blocks
🔹 3. Operators in Python
🔹 4. Taking Input & Output
🔹 5. Control Flow (if-else)
🔹 6. Loops in Python
🔹 7. Lists
🔹 8. Tuples
🔹 9. Strings (Deep Dive)
🔹 10. Dictionaries
🔹 11. Sets
🔹 12. Functions
🔹 13. Modules & Packages
🔹 14. Mini Projects
5. Control Flow (Decision Making)
Control flow lets your program make decisions — like "if it's raining, take umbrella" or "if age > 18, show adult content". Python uses if, elif, else for this.
5.1 if, elif, else Statements
Syntax (basic structure):
Python
if condition: # code runs if condition is True elif another_condition: # optional, can have many # code runs if previous was False and this is True else: # optional # code runs if all above are False
Important Rules:
Colon : after condition
Indentation (usually 4 spaces) is mandatory — Python uses it to know which code belongs to the block
Conditions must evaluate to True or False
Example 1 – Simple if
Python
age = 20 if age >= 18: print("You are an adult. You can vote!")
Output (if age = 20):
text
You are an adult. You can vote!
Example 2 – if + else
Python
temperature = 15 if temperature > 30: print("It's very hot! Wear light clothes.") else: print("It's cool. Enjoy the weather!")
Output (temperature = 15):
text
It's cool. Enjoy the weather!
Example 3 – if + elif + else (most common)
Python
marks = 85 if marks >= 90: print("Grade: A+") elif marks >= 80: print("Grade: A") elif marks >= 70: print("Grade: B") elif marks >= 60: print("Grade: C") else: print("Grade: Fail")
Output (marks = 85):
text
Grade: A
Real-life Example – Traffic Light
Python
light = "red" if light == "green": print("Go!") elif light == "yellow": print("Slow down!") elif light == "red": print("Stop!") else: print("Invalid light color")
Output:
text
Stop!
Tip: You can have as many elif as you want, but else comes only at the end (and is optional).
5.2 Nested if-else
You can put if inside another if — called nested if.
Syntax:
Python
if condition1: if condition2: # both true else: # condition1 true, condition2 false else: # condition1 false
Example – Check eligibility for driving license
Python
age = 17 has_learner = True if age >= 18: if has_learner: print("You can apply for permanent license!") else: print("You need learner's license first.") else: print("You are too young to drive.")
Output (age = 17):
text
You are too young to drive.
Another Example – Login System (nested)
Python
username = "anshuman" password = "python123" if username == "anshuman": if password == "python123": print("Login successful! Welcome back.") else: print("Incorrect password.") else: print("User not found.")
Tip: Avoid too many levels of nesting (max 2–3) — code becomes hard to read. Use logical operators (and, or) instead when possible.
Better version using and:
Python
if username == "anshuman" and password == "python123": print("Login successful!") else: print("Invalid credentials.")
5.3 One-line if / Ternary Operator
Short way to write simple if-else in one line.
Syntax:
Python
value_if_true if condition else value_if_false
Examples:
Basic
Python
age = 20 status = "Adult" if age >= 18 else "Minor" print(status) # Adult
With print
Python
marks = 75 print("Pass" if marks >= 40 else "Fail") # Pass
Assign value
Python
temperature = 35 message = "Hot day" if temperature > 30 else "Normal day" print(message) # Hot day
Nested ternary (possible but avoid deep nesting)
Python
score = 92 grade = "A" if score >= 90 else "B" if score >= 80 else "C" print(grade) # A
When to use: For very short, simple decisions. When NOT to use: For complex logic — use normal if-else for readability.
5.4 pass Statement
pass is a placeholder — does nothing. Used when Python expects a block of code but you don't want to write anything yet.
Common Uses:
Empty if/else blocks during development
Empty functions/classes (later topics)
Ignore certain conditions temporarily
Example:
Python
age = 15 if age >= 18: print("Adult section") else: pass # do nothing for minors right now (maybe add later)
Another Example – Future function
Python
def calculate_tax(income): if income > 1000000: # complex logic later pass else: print("No tax")
Without pass → IndentationError!
Tip: Use pass as a temporary "TODO" marker. Replace it later with real code.
Mini Project – Simple Decision Maker
Python
print("=== Weather Advisor 2026 ===") temp = int(input("Enter current temperature (°C): ")) if temp >= 35: advice = "Very hot! Stay indoors, drink water." elif temp >= 25: advice = "Warm day. Wear light clothes." elif temp >= 15: advice = "Pleasant weather. Enjoy a walk!" else: advice = "Cold! Wear jacket and stay warm." print(f"Advice: {advice}")
Sample Output:
text
=== Weather Advisor 2026 === Enter current temperature (°C): 28 Advice: Warm day. Wear light clothes.
This completes the full Control Flow (Decision Making) section — now your programs can make smart decisions!
📚 Amazon Book Library
All my books are FREE on Amazon Kindle Unlimited🌍 Exclusive Country-Wise Amazon Book Library – Only Here!
On GlobalCodeMaster.com you’ll find complete, ready-to-use lists of my books with direct Amazon links for every country.
Belong to India, Australia, USA, UK, Canada or any other country? Just click your country’s link and enjoy:
✅ Any eBook FREE on Kindle Unlimited ✅ Or buy at incredibly low prices
400+ fresh books written in 2025-2026 with today’s latest AI, Python, Machine Learning & tech trends – nowhere else will you find this complete country-wise collection on one platform!
Choose your country below and start reading instantly 🚀
BOOK LIBRARY USA 2026 LINK
BOOK LIBRARY INDIA 2026 LINK
BOOK LIBRARY AUSTRALIA 2026 LINK
BOOK LIBRARY CANADA 2026 LINK
BOOK LIBRARY UNITED KINGDOM 2026 LINK
BOOK LIBRARY GERMANY 2026 LINK
BOOK LIBRARY FRANCE 2026 LINK
BOOK LIBRARY ITALY 2026 LINK
BOOK LIBRARY SPAIN 2026 LINK
BOOK LIBRARY NETHERLANDS 2026 LINK
BOOK LIBRARY BRAZIL 2026 LINK
BOOK LIBRARY MEXICO 2026 LINK
BOOK LIBRARY JAPAN 2026 LINK
BOOK LIBRARY POLAND 2026 LINK
BOOK LIBRARY IRELAND 2026 LINK
BOOK LIBRARY SWEDEN 2026 LINK
BOOK LIBRARY BELGIUM 2026 LINK
Email-ibm.anshuman@gmail.com
© 2026 CodeForge AI | Privacy Policy |Terms of Service | Contact | Disclaimer | 1000 university college list|book library australia 2026
All my books are exclusively available on Amazon. The free notes/materials on globalcodemaster.com do NOT match even 1% with any of my PUBLISHED BOoks. Similar topics ≠ same content. Books have full details, exercises, chapters & structure — website notes do not.No book content is shared here. We fully comply with Amazon policies.
🚀 Best content for SSC, CGL, LDC, TET, NET & SET preparation!
📚 Maths | Reasoning | GK | Previous Year Questions | Tips & Tricks
👉 Join our WhatsApp Channel now:
🔗 https://whatsapp.com/channel/0029Vb6kg2vFnSz4zknEOG1D...