🐍 Python āĻļেāĻ–া āĻļুāϰু āĻ•āϰি: Syntax āφāϰ Semantics – āĻāĻ•āĻĻāĻŽ āϏāĻšāϜ āĻ­াāώা⧟

Python Syntax āĻāĻŦং Semantics - āĻāĻ•āĻĻāĻŽ āϏāĻšāϜে

Welcome to the very first step of your Python journey!
āĻāχ āĻŦ্āϞāĻ—ে āφāĻŽāϰা āϜাāύāĻŦ Python Programming-āĻāϰ āϏāĻŦāϚে⧟ে āĻŽৌāϞিāĻ• āĻ“ āĻ—ুāϰুāϤ্āĻŦāĻĒূāϰ্āĻŖ āĻĻুāϟি āϜিāύিāϏ: Syntax āφāϰ Semantics

📘 Python Programming āĻļিāĻ–āϤে āĻšāϞে Syntax āφāϰ Semantics āϜাāύāϤেāχ āĻšāĻŦে āĻ•েāύ?

  • ✔️ Syntax āĻ­ুāϞ āĻšāϞে āĻ•োāĻĄ āϚাāϞāĻŦেāχ āύা
  • ✔️ Syntax āĻ িāĻ• āĻšāϞেāĻ“ āϝāĻĻি āĻ•োāĻĄ āĻ­ুāϞ āĻ•াāϜ āĻ•āϰে, āϏেāϟা semantics āĻ­ুāϞ

🔍 Syntax āĻ•ী?

Syntax āĻŽাāύে āĻšāϞো āĻ•োāύো āĻĒ্āϰোāĻ—্āϰাāĻŽিং āĻ­াāώা⧟ āĻ•োāĻĄ āϞেāĻ–াāϰ "grammar" āĻŦা āĻŦ্āϝাāĻ•āϰāĻŖ।

print("Welcome to Python")
print("Welcome to Python"
SyntaxError: unexpected EOF while parsing

🧠 Semantics āĻ•ী?

Semantics āĻŦোāĻা⧟ āĻ•োāĻĄ āϚাāϞাāύোāϰ āĻĒāϰ āϏেāϟি āĻ•ী āĻ•াāϜ āĻ•āϰāĻ›ে, āϤাāϰ āĻŽাāύে āĻŦা āĻŦ্āϝাāĻ–্āϝা।


a = 5
b = 0
c = a / b  # ZeroDivisionError āĻšāĻŦে

📝 Python-āĻ Comment āϞেāĻ–াāϰ āύি⧟āĻŽ

✅ Single-line Comment

# āύিāϚে āχāωāϜাāϰেāϰ āύাāĻŽ print āĻ•āϰা āĻšā§ŸেāĻ›ে
print("Riya")

✅ Multi-line Comment

'''
āĻāχ āĻ•োāĻĄ āĻŦ্āϞāĻ•āϟা
āχāωāϜাāϰেāϰ age print āĻ•āϰāĻŦে।
'''
print(23)
Note: Multi-line comments `.py` āĻĢাāχāϞে āĻ­াāϞো āĻ•াāϜ āĻ•āϰে, Jupyter notebook-āĻ āĻŽাāĻে āĻŽাāĻে output āĻĻেāĻ–া⧟ āύা।

🔤 Python Syntax Rules – āĻŦিāϏ্āϤাāϰিāϤ

1️⃣ Case Sensitivity


roll = 21
Roll = 45

print(roll)  # 21
print(Roll)  # 45

2️⃣ Indentation – Code Structure āĻŦোāĻাāϤে āĻŦ্āϝāĻŦāĻšৃāϤ āĻšā§Ÿ


marks = 90
if marks >= 80:
    print("Distinction")
print("Evaluation complete")

3️⃣ Line Continuation


total_score = 20 + 30 + 40 + \
              25 + 35

4️⃣ Multiple Statements in One Line

x = 5; y = 10; print(x + y)

đŸ§Ē Python Semantics Explained

🔹 Variable Assignment


age = 22       # int
name = "Riya"  # str

print(type(age))       # 
print(type(name))      # 

🔹 Type Inference – Dynamic Typing


status = True
print(type(status))  # bool

status = "Active"
print(type(status))  # str

⚠️ Common Syntax & Semantic Errors

❌ IndentationError


if True:
print("Yes")  # Wrong
Output: IndentationError: expected an indented block

❌ NameError


total = amount + 10  # āϝāĻĻি amount define āύা āĻĨাāĻ•ে
Output: NameError: name 'amount' is not defined

❌ ZeroDivisionError


x = 10
y = 0
z = x / y
Output: ZeroDivisionError: division by zero

🔁 Nested Indentation Example


if True:
    print("Start")
    if False:
        print("Will not print")
    print("Still inside outer if")
print("Outside all blocks")
Output:
Start
Still inside outer if
Outside all blocks

📌 āφāϜāĻ•েāϰ āĻŦ্āϞāĻ—ে āϝা āĻļিāĻ–āϞেāύ:

  • Syntax vs Semantics āĻĒাāϰ্āĻĨāĻ•্āϝ
  • Python-āĻ comments āĻ•িāĻ­াāĻŦে āϞিāĻ–āĻŦেāύ
  • Indentation āĻ•েāύ āĻ—ুāϰুāϤ্āĻŦāĻĒূāϰ্āĻŖ
  • Variable āĻāĻŦং Dynamic Typing
  • Common āĻ­ুāϞ āĻāĻŦং āϏāĻŽাāϧাāύ

🔜 āĻĒāϰāĻŦāϰ্āϤী āĻŦ্āϞāĻ—ে āĻ•ী āφāϏāĻ›ে?

  • 👉 Variables
  • 👉 Data Types
  • 👉 Operators
  • 👉 Input / Output in Python

đŸ“Ŗ āφāĻĒāύাāϰ Turn!

āĻāχ āĻŦ্āϞāĻ— āϝāĻĻি āφāĻĒāύাāϰ āωāĻĒāĻ•াāϰে āφāϏে, āϤাāĻšāϞে āĻ…āύ্āϝāĻĻেāϰ āϏāĻ™্āĻ—ে āĻļে⧟াāϰ āĻ•āϰুāύ, comment āĻ•āϰুāύ, āφāϰ āύি⧟āĻŽিāϤ āϚāϰ্āϚা āϚাāϞি⧟ে āϝাāύ।

Happy Pythoning! 🐍