🐍
Syllabus / Python Programming / Phase 1: Python Basics, Variables, Data Types (Days 1–5)
Beginner

Introduction to Python & Setting Up Your Environment

📂 Phase 1: Python Basics, Variables, Data Types (Days 1–5) · Python Programming

Python is a high-level, interpreted programming language known for its clean, readable syntax — code reads almost like plain English, which is a big part of why it has become one of the most widely used languages in web development, automation, data science, and AI.

Why Python Looks So Different From Java or C++

AspectPythonJava / C++
ExecutionInterpreted (runs line by line)Compiled to bytecode/machine code first
TypingDynamically typed — no type declarations neededStatically typed — every variable needs a declared type
SyntaxIndentation defines blocks (no curly braces)Curly braces {} define blocks
SemicolonsNot requiredRequired to end statements

Installing Python

Download the latest Python 3 release from python.org — Python 2 reached end-of-life years ago and should never be used for new learning or projects. During installation on Windows, make sure to check "Add Python to PATH" so it can be run from any terminal.

python --version
# or on some systems:
python3 --version

Choosing an Editor

VS Code with the official Python extension is the most common choice for beginners and professionals alike — lightweight, free, and with excellent debugging support. Many learners also start in the interactive Python shell (just type python in a terminal) to experiment line by line before writing full scripts.

Your First Python Program

print("Hello, World!")

That single line is a complete, runnable Python program — no class definition, no main method, no semicolon. Save it as hello.py and run it from the terminal:

python hello.py

Comments in Python

# This is a single-line comment

"""
This is a multi-line comment,
often used for documentation.
"""

print("Comments are ignored when the code runs")

Taking User Input

name = input("What is your name? ")
print("Hello, " + name + "!")

The input() function always returns a string, even if the user types a number — this becomes important once you start doing math with user-entered values, covered in the next lesson.

Indentation Is Not Optional

Unlike Java or C++, where indentation is purely a style choice, in Python it is part of the syntax itself. Code at the same logical level must be indented identically, or the program will throw an IndentationError.

if True:
    print("This line is part of the if block")
    print("So is this one")
print("This line is NOT part of the if block")
Interview tip: A common early question is "Is Python compiled or interpreted?" — the precise answer is that Python source code is first compiled to bytecode (.pyc files) and then that bytecode is interpreted by the Python Virtual Machine (PVM), so it is technically a hybrid, though it is commonly described simply as "interpreted."