Introduction to Python
What Python actually is, how a script runs, and your first program.
Python is a high-level, interpreted programming language — "interpreted" means you don't compile it into a separate binary first; the Python interpreter reads your .py file and runs it directly, line by line. That's why you can write a script and run it in seconds, which is a big part of why it's the default choice for scripting, data science, automation, and backend web development (including the CodeWithMunnaX channel's own backend demos).
Your first program
print("Hello, CodeWithMunnaX!")
Save this as hello.py and run it with python hello.py (or python3 hello.py on systems where python still points to Python 2). print() is a built-in function — you're calling it with one argument, the text to display.
Comments
Anything after # on a line is ignored by the interpreter — comments exist purely for humans reading the code.
# This is a single-line comment
print("This runs") # comments can also trail after code
"""
This is a multi-line string.
When it's not assigned to anything, it's often used as a
multi-line comment or a docstring at the top of a function/class.
"""
Indentation is syntax, not style
Most languages use { } to mark a block of code. Python uses indentation — consistent whitespace at the start of a line. Mixing tabs and spaces, or indenting inconsistently, is a syntax error, not just a style complaint.
if True:
print("This is inside the if block")
print("So is this")
print("This is outside the if block")
The convention (PEP 8, Python's official style guide) is 4 spaces per indentation level — that's also what this playground's editor inserts when you press Tab.
- •Python is interpreted — the interpreter runs your .py file directly, no separate compile step.
- •print() writes text to the console; # starts a comment that runs to the end of the line.
- •Indentation defines code blocks in Python — it's mandatory syntax, not a style preference.
- •The standard is 4 spaces per indent level (PEP 8), and you shouldn't mix tabs and spaces.
hello.py
Revision Flashcards
Tap a card to flip it and see the answer.