80 terms
A step-by-step set of instructions for solving a problem. Like a recipe — it takes an input, follows a fixed sequence of steps, and produces an output. The key property: given the same input, an algorithm always produces the same output.
# Finding the largest number in a list is an algorithm
numbers = [3, 7, 2, 9, 1]
largest = max(numbers) # Python's built-in uses an algorithm internally
Algorithms on The Codex →
A defined set of rules for how two pieces of software talk to each other. When you use a weather app, the app sends a request to a weather service's API and gets back data. You don't need to know how the weather service works — you just need to know what to ask and what format the answer comes back in.
# Calling a web API with Python's requests library
import requests
response = requests.get("https://api.example.com/weather?city=Mumbai")
data = response.json() # Parse the response as JSON
A value you pass into a function when you call it. If a function is a recipe, arguments are the ingredients you hand it. Not to be confused with parameter — the parameter is the name in the function definition; the argument is the actual value you pass in.
def greet(name): # 'name' is the PARAMETER
print(f"Hello, {name}!")
greet("Priya") # "Priya" is the ARGUMENT
A collection of items stored in order, one after another. You can access any item directly by its position (called an index). In Python, this is called a list. In other languages it may be called an array, vector, or ArrayList.
fruits = ["apple", "banana", "cherry"]
print(fruits[0]) # "apple" — index 0 is the first item
print(fruits[2]) # "cherry" — index 2 is the third item
Arrays deep dive →
Code that can start a task and move on to other work while waiting for it to finish — rather than stopping and waiting. Like ordering food at a restaurant: you don't stand at the counter staring until your order is ready, you go sit down and do other things. Useful when your program spends time waiting for network requests or file reads.
import asyncio
async def fetch_data():
await asyncio.sleep(1) # Waits without blocking other tasks
return "done"
A value that is either True or False — nothing else. Named after mathematician George Boole. Used to make decisions in code: if something is True, do this; if False, do that. In Python, True and False are written with capital letters.
is_logged_in = True
has_paid = False
if is_logged_in and has_paid:
print("Welcome!") # Only runs if BOTH are True
A mistake in code that causes it to behave in an unintended way. Bugs can be typos, logic errors, or incorrect assumptions about how data will look. The process of finding and fixing bugs is called debugging.
A blueprint for creating objects. A class defines what data an object holds (attributes) and what actions it can perform (methods). Like a house blueprint — the blueprint isn't a house, but you can build many houses from it, each with the same structure but their own rooms.
class Dog:
def __init__(self, name):
self.name = name # Each dog has its own name
def bark(self):
print(f"{self.name} says: Woof!")
my_dog = Dog("Bruno")
my_dog.bark() # "Bruno says: Woof!"
Classes deep dive →
Text in your code that the computer ignores — written for humans to read. Used to explain what code does, why a decision was made, or to temporarily disable a line of code. In Python, comments start with #.
price = 100 # Price in Indian Rupees
# The tax rate is 18% GST
tax = price * 0.18
A compiler translates your entire program from human-readable code into machine code before it runs — like translating a whole book before handing it to the reader. Languages like C, C++, Rust, and Go are compiled. Contrast with interpreted languages (Python, JavaScript) where code is translated line by line as it runs.
Compilation explained →A statement that runs different code depending on whether something is true or false. The most common form is if / else. Think of it as a fork in the road — your program chooses which path to take based on a condition.
age = 17
if age >= 18:
print("You can vote")
else:
print("Too young to vote")
The text-based window where your program's output appears and where you can type input. When you run print("Hello") in Python, the output appears in the console. Also called the terminal, command line, or shell.
A way of organising data so it can be used efficiently. Different structures are good for different things — a list is good for ordered items, a dictionary is good for looking things up by name, a set is good for checking if something exists. Choosing the right data structure can make your program much faster.
Data structures on The Codex →The process of finding and fixing mistakes (bugs) in code. Debugging often involves reading error messages, adding print() statements to see what's happening inside the program, and working through the code step by step to find where it goes wrong.
A collection that stores data as key-value pairs. Instead of accessing items by position (like a list), you access them by a unique key — like looking up a word in a dictionary to find its definition. In Python it's called a dict; in JavaScript an object or Map.
person = {
"name": "Arjun",
"age": 25,
"city": "Bengaluru"
}
print(person["name"]) # "Arjun"
Hash tables deep dive →
An error that happens while a program is running — not a typo (that's a syntax error), but something unexpected like dividing by zero, trying to open a file that doesn't exist, or getting the wrong type of input. In Python you handle exceptions with try/except.
try:
result = 10 / 0 # This causes a ZeroDivisionError
except ZeroDivisionError:
print("Can't divide by zero!") # Program continues
Error handling deep dive →
A named, reusable block of code that performs a specific task. You define it once and call it as many times as you need. Functions take in data (arguments), do something with it, and usually return a result. They prevent you from writing the same code over and over.
def add(a, b):
return a + b
print(add(3, 5)) # 8
print(add(10, 20)) # 30 — same function, different inputs
Functions deep dive →
A way to repeat a block of code for each item in a collection. Instead of writing the same code five times for five items, a for loop does it automatically. See also: Loop, While Loop.
cities = ["Mumbai", "Delhi", "Bengaluru"]
for city in cities:
print(f"Hello from {city}!")
# Prints all three cities without repeating the print line
A pre-built structure that handles the common, repetitive parts of building a certain kind of software — so you can focus on what makes your project unique. Django is a web framework for Python: it handles routing, databases, and templates, and you fill in your specific logic. Different from a library — a framework tells you where to put your code; a library gives you tools you call when you need them.
A tool that tracks every change you make to your code over time, so you can go back to any previous version. It also lets multiple people work on the same codebase without overwriting each other's work. GitHub and GitLab are websites that host Git repositories online.
Writing a specific value directly into your code instead of making it a variable or reading it from a configuration. Generally considered bad practice because it makes the code harder to change later. "Don't hardcode the tax rate — put it in a variable so it's easy to update."
# Bad — hardcoded
price_with_tax = price * 1.18
# Better — named variable
GST_RATE = 0.18
price_with_tax = price * (1 + GST_RATE)
The most basic decision-making tool in programming. If a condition is true, run this code. If it's false, either skip it or run different code. See Conditional.
A number used to access a specific item in an ordered collection (like a list or string). In almost all programming languages, indexing starts at 0, not 1. So the first item is at index 0, the second at index 1, and so on. This catches beginners off guard constantly.
name = "Python"
print(name[0]) # "P" — the FIRST character is at index 0
print(name[1]) # "y"
print(name[-1]) # "n" — negative index counts from the end
A way for one class to automatically get all the properties and behaviours of another class, and then add or change things. Like a child inheriting traits from a parent. The child class (subclass) extends the parent class (superclass).
class Animal:
def breathe(self):
print("Breathing...")
class Dog(Animal): # Dog inherits from Animal
def bark(self):
print("Woof!")
d = Dog()
d.breathe() # Works! Inherited from Animal
d.bark() # Dog's own method
Inheritance deep dive →
A whole number — no decimal point. Examples: -3, 0, 7, 100. In Python the type is called int. Contrast with float (a number with a decimal point like 3.14).
age = 25 # int
price = 99.99 # float
print(type(age)) # <class 'int'>
An interpreter runs your code line by line — translating and executing each line as it goes, without producing a separate executable file first. Python and JavaScript are interpreted. Contrast with compiled languages. Interpreted languages are usually easier to start with (no build step) but may be slower for heavy computation.
Interpretation explained →Going through a collection of items one by one. A for loop iterates over a list — it visits each item in turn and runs the same code for each one. One pass through all the items is called one iteration.
A simple text format for storing and transferring data. It looks like a Python dictionary — keys and values, in curly braces. It's the most common format for data sent between a web server and a browser or app. Despite the name, it's used in all languages, not just JavaScript.
{"name": "Kavya", "age": 28, "city": "Hyderabad"}
Python json module →
A word that Python (or any language) has already claimed for its own purposes — you can't use it as a variable name. Examples in Python: if, for, while, def, class, return, import, True, False, None.
A collection of pre-written code that you can import into your program to use. Instead of writing everything yourself, you import a library and use its functions. Python's standard library comes built in; external libraries (like NumPy or requests) are installed with pip.
import random # Built-in library
import requests # External library (install with: pip install requests)
random.randint(1, 10) # Use a function from the library
A way to repeat a block of code multiple times without writing it out repeatedly. The two main loops are for (repeat for each item in a collection) and while (repeat as long as a condition is true). See also: For Loop, While Loop.
A function that belongs to a class or object. You call it using dot notation: object.method(). The difference from a regular function: a method has automatic access to the object's own data (via self in Python).
name = "hello"
print(name.upper()) # .upper() is a method of string objects
# Output: "HELLO"
A file containing Python code (functions, classes, variables) that can be imported and used in other files. When your program gets large, you split it into modules to keep things organised. Python's standard library is a collection of built-in modules.
import math # Import the math module
print(math.sqrt(16)) # Use a function from it: 4.0
Modules deep dive →
Mutable means the value can be changed after it's created. Immutable means it can't — you'd have to create a new one. In Python: lists are mutable (you can add/remove items), strings and tuples are immutable. This distinction matters because mutable objects passed to functions can be changed by those functions.
my_list = [1, 2, 3]
my_list.append(4) # OK — lists are mutable
print(my_list) # [1, 2, 3, 4]
my_str = "hello"
my_str[0] = "H" # ERROR — strings are immutable
Python's way of representing "nothing" or "no value". A variable set to None exists but has no useful value yet. Many functions return None when they have nothing to return. In other languages this is called null, nil, or undefined.
result = None # No value yet
print(result) # None
def say_hi():
print("Hi!") # No return statement
x = say_hi() # x is None — function returned nothing
A single instance created from a class. If a class is a blueprint, an object is the actual thing built from it. One class can create many objects, each with their own data. In Python, almost everything is an object — numbers, strings, lists, functions.
class Car:
def __init__(self, brand):
self.brand = brand
car1 = Car("Maruti") # car1 is one object
car2 = Car("Tata") # car2 is a different object
# Both came from the same Car class
Objects deep dive →
A way of organising code around "objects" — things that have data (what they know) and behaviour (what they can do). Instead of writing a long list of instructions, you model your problem as interacting objects. Python, Java, C++, and most modern languages support OOP.
OOP explained →A symbol that performs an operation on values. Arithmetic operators: + - * / // (floor divide) % ** (power). Comparison operators: == != < > <= >=. Logical operators: and or not.
print(10 + 3) # 13 — addition
print(10 ** 2) # 100 — power (10 squared)
print(10 % 3) # 1 — remainder (modulo)
print(5 == 5) # True
The named placeholder in a function definition that will hold the value when the function is called. Parameters are defined; arguments are passed. See also: Argument.
def greet(name): # 'name' is the PARAMETER
print(f"Hello, {name}!")
greet("Riya") # "Riya" is the ARGUMENT
Python's built-in package manager — the tool you use to install external libraries. Run it in your terminal. Most Python libraries you'll want (requests, numpy, pandas, flask) are installed with pip.
pip install requests # Install the requests library
pip install numpy # Install numpy
pip list # See what's installed
Python's built-in function for displaying output. Whatever you put inside the brackets gets shown in the console. The single most-used tool for understanding what's happening inside your code.
print("Hello, World!") # Text
print(42) # Number
print("Answer:", 6 * 7) # Multiple things: "Answer: 42"
name = "Saanvi"
print(f"Hello, {name}!") # f-string: "Hello, Saanvi!"
An informal way of planning code using plain English (or any human language) instead of real programming syntax. You write down the logic of what your program needs to do before worrying about the exact code. Useful for thinking through a problem before you start typing.
# Pseudocode for a login check:
# Get username and password from user
# Check if username exists in database
# If yes, check if password matches
# If both correct, let user in
# Otherwise, show error
When a function calls itself. Useful for problems that can be broken down into smaller versions of the same problem — like calculating a factorial, traversing a file tree, or solving a maze. Every recursive function needs a base case that stops it from calling itself forever.
def factorial(n):
if n == 0: # Base case — stop here
return 1
return n * factorial(n - 1) # Function calls itself
print(factorial(5)) # 120
Recursion deep dive →
The value a function sends back when it finishes. The return statement exits the function and passes a value back to wherever the function was called. If a function has no return statement, it returns None.
def square(n):
return n * n # Sends n*n back to the caller
result = square(7) # result = 49
print(result) # 49
The period of time when a program is actually executing — as opposed to when it's being written (development time) or compiled (compile time). A runtime error is one that only happens when the program is running, not a typo the editor could catch beforehand.
Where a variable can be seen and used. A variable created inside a function only exists inside that function (local scope) — code outside the function can't see it. Variables created outside all functions exist in global scope and can be seen everywhere. Understanding scope prevents a huge category of bugs.
message = "I'm global" # Global scope
def show():
local_msg = "I'm local" # Local scope — only exists inside show()
print(message) # Can see global variable
show()
print(local_msg) # ERROR — local_msg doesn't exist out here
Scope deep dive →
A sequence of characters — text. In Python, strings are written in single quotes 'like this' or double quotes "like this". Strings are immutable — you can't change individual characters, but you can create new strings from them.
greeting = "Namaste"
print(len(greeting)) # 7 — number of characters
print(greeting.upper()) # "NAMASTE"
print(greeting[0]) # "N" — first character
A mistake in the grammar of your code — like a typo or missing punctuation. Python can't even start running code with a syntax error. Common causes: missing colon after if or def, unclosed brackets, wrong indentation. The error message usually tells you the line number.
def greet(name) # SyntaxError: missing colon at the end
print(name)
An ordered collection like a list, but immutable — once created, you can't add, remove, or change items. Written with round brackets. Used when you want to make clear that this group of values shouldn't change, or as a dictionary key (lists can't be keys; tuples can).
coordinates = (28.6, 77.2) # Latitude, longitude — shouldn't change
print(coordinates[0]) # 28.6
# coordinates[0] = 0 # ERROR — tuples are immutable
What kind of data a value is. Python's main built-in types: int (whole number), float (decimal number), str (text), bool (True/False), list (ordered collection), dict (key-value pairs), tuple (immutable list), set (unique items), None (nothing). The type determines what operations you can do with a value.
print(type(42)) # <class 'int'>
print(type(3.14)) # <class 'float'>
print(type("hello")) # <class 'str'>
print(type(True)) # <class 'bool'>
Data types deep dive →
A named container that stores a value. You give it a name, assign a value to it with =, and then use the name later to retrieve or change that value. Variables are the most fundamental concept in programming.
age = 22 # Store the value 22 in a variable called 'age'
name = "Rohit" # Store text
print(name, "is", age, "years old") # Use the variables
age = 23 # Change the value — that's why it's called a VARiable
Variables deep dive →
A loop that keeps repeating as long as a condition stays true. Unlike a for loop (which runs a fixed number of times), a while loop keeps going until something changes. Be careful — if the condition never becomes false, the loop runs forever (an infinite loop).
count = 0
while count < 5:
print(count)
count += 1 # Without this line, it would loop forever
# Prints 0, 1, 2, 3, 4