R
Rishtaara
Python: Zero to Professional
Lesson 2 of 40Article14 minFREE

Syntax, Output & Comments

Python uses indentation (spaces) to define blocks — not curly braces. A colon (:) starts a block after if, for, def, and class.

Python Syntax

Python uses indentation (spaces) to define blocks — not curly braces. A colon (:) starts a block after if, for, def, and class.

Python is case-sensitive: name and Name are different variables.

Real-life example: Indentation is like margins in a notebook — wrong margins make the teacher think your answer belongs to the wrong question.

Indentation matters
score = 85
if score >= 60:
    print("Pass")  # indented block
print("Done")

Python Output

print() sends text to the screen. You can print variables, expressions, and multiple items separated by commas.

f-strings (f"...") embed values inside strings cleanly.

Real-life example: print() is like speaking out loud in class — everyone sees the result immediately on the screen.

print() and f-strings
name = "Aarav"
print("Hello", name)
print(f"Hello {name}, welcome to Rishtaara!")

Python Comments

Comments start with # for one line. Triple quotes """ ... """ can document functions and classes.

Comments explain why — not what obvious code already shows.

Real-life example: Comments are sticky notes on your fridge — reminders for you, ignored by guests (the computer).

Single-line and doc comments
# This line is a comment
price = 100  # discount base price

def add_tax(amount):
    """Add 18% tax and return total."""
    return amount * 1.18