Welcome to Python: What It Is and Why It Matters

Python is a general-purpose, high-level programming language created by Guido van Rossum and first released in 1991. It was designed around one core idea: code should be easy to read, even by someone who didn’t write it. That focus on readability is why Python has become one of the most widely used languages in the […]

Variables, Data Types and Type Conversion

A variable is a name that points to a value stored in memory. Unlike languages such as Java or C++, Python never asks you to declare a variable’s type up front — it figures the type out automatically based on whatever value you assign, and that type can even change later if you assign something […]

Operators and Expressions

Operators combine values into expressions, and Python groups them into a few families you’ll use constantly in almost every program you write. Arithmetic 7 + 3 # 10 7 – 3 # 4 7 * 3 # 21 7 / 3 # 2.333… (always returns a float) 7 // 3 # 2 (floor division — […]

Control Flow: if/elif/else and Loops

Making decisions score = 82 if score >= 90: grade = “A” elif score >= 75: grade = “B” else: grade = “C” print(grade) # B Python checks each condition in order, top to bottom, and runs the first block whose condition is True — everything after that is skipped, even if a later condition […]

Functions and Scope

A function packages up reusable logic so you’re not repeating yourself every time you need to perform the same task. Once you’ve written and tested a function, you can call it from anywhere in your program with confidence that it behaves the same way each time. def greet(name, greeting=”Hello”): return f”{greeting}, {name}!” print(greet(“Yash”)) # Hello, […]

Lists, Tuples and Dictionaries

Lists — ordered, changeable courses = [“Python”, “JavaScript”, “SQL”] courses.append(“Java”) courses[0] = “Python 3” print(courses) # [‘Python 3’, ‘JavaScript’, ‘SQL’, ‘Java’] print(len(courses)) # 4 print(courses[-1]) # ‘Java’ — negative indexing counts from the end Lists are the workhorse data structure in Python: ordered, indexable, and able to grow or shrink freely with methods like append(), […]

Object-Oriented Programming Basics

A class is a blueprint for creating objects that bundle data (attributes) and behavior (methods) together. Instead of passing a dictionary around between separate functions, you can define a Course class that knows both its own data and what it’s able to do. class Course: def __init__(self, title, lessons): self.title = title self.lessons = lessons […]

File Handling and What’s Next

Reading a file with open(“notes.txt”, “r”) as f: content = f.read() print(content) The with statement automatically closes the file when the block ends, even if an error occurs partway through — always prefer it over calling open() directly and remembering to call .close() yourself, which is easy to forget and can leave files locked or […]

Comprehensions and Generators

Experienced Python code rarely builds a list with a manual loop when it can build one in a single, readable expression instead. This lesson covers the idioms that separate beginner Python from professional Python. List comprehensions squares = [n ** 2 for n in range(10)] even_squares = [n ** 2 for n in range(10) if […]