Glossary in Python
Python Glossary
Here's a glossary of commonly used terms and concepts in Python programming to help you better understand the language.
? A - C
Algorithm
A set of steps or instructions to solve a problem or perform a task.
Array
A collection of items (usually of the same type) stored at contiguous memory locations. In Python, arrays are commonly implemented using lists or the array module.
Argument
A value passed to a function or method when it is called.
Boolean
A data type that can hold one of two possible values: True or False.
Class
A blueprint for creating objects, defining methods and properties.
Compiler
A program that translates source code into machine code or bytecode. Python is interpreted, but the Python interpreter compiles the code to bytecode before execution.
Constructor
A special method in a class that is called when an object is created. In Python, it's the __init__() method.
? D - F
Debugger
A tool used to examine and debug the code by stepping through execution, inspecting variables, and fixing errors.
Dictionary
An unordered collection of key-value pairs. Also known as a hash map or associative array.
Example:
person = {"name": "Alice", "age": 30}Exception
An error that occurs during the execution of a program, which can be caught and handled using try and except blocks.
File Handling
Operations that involve reading from and writing to files.
# Example of reading from a filewith open("file.txt", "r") as file: content = file.read()Function
A reusable block of code designed to perform a specific task.
def greet(name): return f"Hello, {name}!"? G - L
Global Variable
A variable that is defined outside of any function or class and can be accessed throughout the entire program.
Indentation
The use of spaces or tabs to define the structure of Python code. Indentation is important because it determines code blocks (loops, conditionals, functions).
Interpreter
A program that reads and executes code line by line. Python is an interpreted language, meaning the Python interpreter executes your code directly.
List
An ordered collection of items that are mutable. Lists can contain different data types.
numbers = [1, 2, 3, 4]Lambda Function
A small anonymous function defined with the lambda keyword.
add = lambda x, y: x + y? M - P
Module
A file containing Python code that defines functions, variables, and classes. Python's standard library is a collection of modules that provide built-in functionalities.
import math # math is a moduleObject
An instance of a class that contains both data and methods to manipulate that data.
Operator
A symbol that performs a specific operation on one or more operands. Examples include arithmetic (+, -, *), comparison (==, !=), and logical (and, or) operators.
Package
A collection of modules organized in a directory hierarchy. A package can include subdirectories and other packages.
Parent Class
A class that is inherited by another class (the child class). It is the base class in object-oriented programming.
? Q - T
Recursion
A programming technique where a function calls itself to solve smaller instances of a problem.
def factorial(n): if n == 1: return 1 else: return n * factorial(n-1)Return
The value that a function sends back to the caller. The return statement terminates the function.
def add(x, y): return x + ySet
An unordered collection of unique elements.
unique_numbers = {1, 2, 3}Slice
A way to access a range of elements from a list, tuple, or string using the start:stop syntax.
numbers = [1, 2, 3, 4]print(numbers[1:3]) # Output: [2, 3]String
A sequence of characters enclosed in quotes.
name = "Alice"? U - Z
Variable
A named location used to store data that can be changed during the execution of a program.
x = 10 # x is a variableWhile Loop
A loop that repeatedly executes as long as a specified condition is True.
count = 0while count < 5: print(count) count += 1Yield
A keyword used in a function to return a value, but it allows the function to resume from where it left off when called again. This is used in generators.
def count_up_to(max): count = 1 while count <= max: yield count count += 1Summary
This glossary introduces essential terms in Python programming, from variables and functions to modules and loops. Understanding these concepts will provide a solid foundation for writing Python programs and building applications. Let me know if you'd like more detailed explanations of any specific terms!