Python Control Flow Explained in Bengali

Python Control Flow Explained in Bengali-English

🧭 Python Control Flow Explained in Bengali-English

🔰 āĻ­ূāĻŽিāĻ•া

Python-āĻāϰ Control Flow āĻŦোāĻা āĻāĻ•āϟি āĻ—ুāϰুāϤ্āĻŦāĻĒূāϰ্āĻŖ āĻŦিāώāϝ়, āĻ•াāϰāĻŖ āĻāϟি āφāĻŽাāĻĻেāϰāĻ•ে āĻ•োāĻĄেāϰ āĻŽāϧ্āϝ āĻĻিāϝ়ে āϏিāĻĻ্āϧাāύ্āϤ āύেāĻ“āϝ়াāϰ āĻ•্āώāĻŽāϤা āĻĻেāϝ়। Control Flow-āĻāϰ āĻĒ্āϰāϧাāύ āωāĻĒাāĻĻাāύ āĻšāϞো if, else, elif āĻāĻŦং nested conditional statements। āĻāχ āĻŦ্āϞāĻ—ে āφāĻŽāϰা āĻŦাāϏ্āϤāĻŦ āωāĻĻাāĻšāϰāĻŖāϏāĻš āĻāĻ—ুāϞো āĻŦিāĻļ্āϞেāώāĻŖ āĻ•āϰāĻŦো।

✅ If Statement

If āϏ্āϟেāϟāĻŽেāύ্āϟ āĻŦ্āϝāĻŦāĻšাāϰ āĻ•āϰে āφāĻŽāϰা āĻāĻ•āϟি āĻļāϰ্āϤ āϝাāϚাāχ āĻ•āϰে āĻĻেāĻ–ি āϏেāϟি True āĻšāϞে āύিāϰ্āĻĻিāώ্āϟ āĻ•োāĻĄ āĻŦ্āϞāĻ• āϚাāϞাāύো āĻšāĻŦে।

vote_age = 21
if vote_age >= 18:
    print("You are eligible to vote.")

āϝেāĻšেāϤু vote_age āĻšāϞ 21, āĻāϟি 18-āĻāϰ āϏāĻŽাāύ āĻŦা āĻŦāĻĄ়, āϤাāχ āĻŽেāϏেāϜāϟি āĻĒ্āϰিāύ্āϟ āĻšāĻŦে।

➡️ Else Statement

Else āĻŦ্āϝāĻŦāĻšাāϰ āĻ•āϰা āĻšāϝ় āϝāĻ–āύ if āĻļāϰ্āϤāϟি False āĻšāϝ়।

vote_age = 16
if vote_age >= 18:
    print("You are eligible to vote.")
else:
    print("You are a minor.")

āϝেāĻšেāϤু 16 āĻšāϞ 18-āĻāϰ āĻ•āĻŽ, else āĻŦ্āϞāĻ• āϚাāϞু āĻšāĻŦে।

🔁 Elif Statement

Elif āĻŽাāύে "else if"। āĻāϟি āĻŦ্āϝāĻŦāĻšাāϰ āĻ•āϰা āĻšāϝ় āĻāĻ•াāϧিāĻ• āĻļāϰ্āϤ āĻĒāϰীāĻ•্āώা āĻ•āϰাāϰ āϜāύ্āϝ।

user_age = 15
if user_age < 13:
    print("You are a child.")
elif user_age < 18:
    print("You are a teenager.")
else:
    print("You are an adult.")

āĻāχ āĻ•োāĻĄে user_age 15, āϤাāχ "teenager" āĻĒ্āϰিāύ্āϟ āĻšāĻŦে।

🔄 Nested If Statements

Nested if āĻšāϞো āĻāĻ•āϟি if āĻŦা else āĻŦ্āϞāĻ•েāϰ āĻŽāϧ্āϝে āφāϰেāĻ•āϟি if āĻŦা elif āϞেāĻ–া।

num = 14
if num > 0:
    print("Positive number")
    if num % 2 == 0:
        print("Even number")
    else:
        print("Odd number")
else:
    print("Negative or Zero")

āĻāχ āωāĻĻাāĻšāϰāĻŖে 14 āĻšāϞ Positive āĻāĻŦং Even number।

📅 Leap Year Checker (Practical Example)

input_year = int(input("Enter the year: "))
if input_year % 4 == 0:
    if input_year % 100 == 0:
        if input_year % 400 == 0:
            print(f"{input_year} is a leap year")
        else:
            print(f"{input_year} is not a leap year")
    else:
        print(f"{input_year} is a leap year")
else:
    print(f"{input_year} is not a leap year")

📝 Practice Quiz

  1. What will be the output of if 10 > 5:?
    • a) Syntax Error
    • b) True
    • ✅ c) Executes the block under if
    • d) False
  2. Which operator is used to check multiple conditions?
    • a) ==
    • b) or
    • ✅ c) elif
    • d) not
  3. Which of these is a correct syntax for an if statement?
    • a) if x > 5 then:
    • b) if(x > 5)
    • ✅ c) if x > 5:
    • d) if > 5 x:
  4. What is the output of the following?
    vote_age = 16
    if vote_age >= 18:
        print("Adult")
    else:
        print("Minor")
    • a) Adult
    • ✅ b) Minor
    • c) Error
    • d) Nothing
  5. What is the purpose of indentation in if-else block?
    • a) To create loops
    • b) For better appearance
    • ✅ c) To define code block scope
    • d) None of the above

📅 āφāĻĒāĻĄেāϟেāĻĄ: July 2025