Python Vocabulary Terms

Algorithm
A well-defined sequence of steps for solving a particular type of problem.
Argument
A value provided to a function when it is called.
Assignment
The process of assigning a value to a variable or data structure.
Boolean
A data type that has one of two possible values, often denoted as true or false.
Boolean Expression
An expression which results in either “True” or “False”
Bug
An error in a program
Class
A blueprint for creating objects in object-oriented programming.It defines a set of attributes (data members) and methods (functions) that the objects created from it will have. Created by using the keyword “class”.
Comment
Written information in a program that is meant for other programmers (or anyone reading the source code and has no effect on the execution of the program.) A comment is begun with a hash symbol
 # like this.
They can also be written on multiple lines within triple quotes
 ''' like this.'''
Compile
To translate a program written in a high-level language into a low-level language
Concatenate
To join two or more objects together, typically strings
“Hello_” + “world” == “Hello_world”
Constructor
A special method in a class that is called when an object is created. It initializes the object's attributes. The constructor method has the same name as the class and is defined using the init() function.
Control Flow
Methods of executing code in a specific order based on different conditions or criteria. Includes branching (conditional statements) and looping.
Data Structure
A container that holds data in a particular way, allowing for efficient storage, access, and modification of data. Examples of data structures include lists, tuples, and dictionaries.
Data Type
A classification of data based on its nature and intended use
Debug
The process of finding and removing programming errors or bugs. Debugging often involves using tools like print statements or a dedicated debugger to identify issues and fix them.
Debugger
A program or tool (often built into an IDE) that helps identify and resolve errors in a program. Debuggers allow developers to execute code step-by-step, inspect variables and memory, and track program flow, making it easier to identify bugs.
Declaration
A statement that creates a new variable and optionally assigns an initial value to it. In Python, variables can be declared simply by assigning a value to them, without explicitly declaring their type. For example, x = 5 creates a new variable named x and assigns it the value 5.
Dictionary
An ordered and mutable data structure that stores key-value pairs; unique keys mapped to values. Dictionaries are enclosed in curly braces, key-value pairs are separated by commas, and keys are paired with values with a colon. Example:
dict1 = {“key1”:5, “key2”:“blue”, “key3”:[list1]}
Exception
An event that occurs during the execution of a program that disrupts the normal flow of instructions. Examples include division by zero and trying to access a non-existent file.
Float
Short for 'floating point number'. A data type representing real fractional numbers (numbers with decimals.)
Function
A block of code that performs a specific task and can be called (reused.) Functions help break code into smaller, more manageable pieces. They may or may not take one or more arguments and may or may not return a resulting value. Many functions are built into Python by default. Additional functions are defined by the programmer.
    Function Header
    The first line of a function definition, specifying its name and parameters. Created by using "def".
    Parameter
    A variable declared in the function definition that receives a value (an argument) when the function is called. Parameters allow different values to be passed in as arguments each time the function is called.
    Function Body
    The sequence of statements inside a function definition.
    Return Value
    The value given by a function when it is completed. Created by using “return”.
    Function Call
    A statement that executes a function. It consists of the function name followed by an argument list.
High-level Language
A programming language that is designed to be easy for humans to read and write. They are typically closer to human language than machine language, and include constructs that abstract away the details of the computer's architecture. Examples include Python, Java, and C#.
IDE
Integrated development environment. An application designed for writing, testing, and debugging code. Consists of a source code editor, build automation (to compile and run tests on the code,) and a debugger. A good IDE provides visual aids such as syntax highlighting and other conveniences.
Index
A number used to represent the position of an element in a sequence, such as a string or a list. In Python, indexing starts at 0, so the first element in a sequence has an index of 0, the second has an index of 1, and so on. Negative indexing can also be used, where -1 represents the last element in a sequence, -2 represents the second-to-last element, and so on.
Inheritance
A mechanism in object-oriented programming that allows a new class to be based on an existing class. The new “child” class inherits the attributes and methods of the existing “parent” class, and can then be given additional attributes and methods.
Integer
A data type representing non-decimal numbers.
Interpret
To execute a program in a high-level language by translating it one line at a time.
Iterable
An object capable of returning its members one at a time, permitting it to be iterated over in a for-loop. Includes lists and dictionaries.
Iteration
The process of repeatedly executing a set of statements until a specific condition is met; in other words, the repeated execution of a block of code using either a recursive function call or a loop.
Keywords
Reserved words that are used by the compiler to parse a program. Cannot be used as variable names or function names.
Looping
Executing a code block repeatedly, either for a set number of iterations or until a certain condition is met. Includes “for” loops and “while” loops.
    For Loop
    Used for iterating over a sequence (string, list, dictionary, etc.) Executes the same block of code for every item in that sequence.
    While Loop
    Used to repeatedly execute a block of code as long as a specified condition (the “while condition”) is true.
    Break Statement
    Used to exit a loop prematurely with the “break” keyword.
    Infinite Loop
    A loop in which the terminating condition is never satisfied.
List
A data structure representing a sequence of values, each associated with an index. Created with square brackets. Examples:
 list1 = [1999, 2001, 2008, 2014, 2018]
list2 = [“red”, “blue”, “gold”, “silver”]
list3 = [0, “mushroom”, [list1]]
Low Level Language
A programming language designed to be closer to the binary machine language of the computer. They provide more direct access to the hardware and are often used for systems programming or other tasks that require direct manipulation of hardware resources. Examples include assembly language and machine language. “High level” and “low level” is a relative term, and changes over time; languages that were once considered high level are now considered low level languages. C++ is considered a high level language, but it is low level compared to Python, for example.
Method
A function that is associated with an object and called using dot notation. Often used interchangeably with “function.”
Module
A file containing Python definitions and statements, intended to be imported and used in other Python programs. Modules can contain functions, classes, and other definitions, and can be organized into packages to help manage larger programs.
    Import Statement
    A statement used to import a module into a program. The module's functions, classes, and other definitions can then be used in the program.
    Module Object
    A value created by an "import" statement that provides access to the values defined in a module.
Mutability
If the value of an object can be changed, the object is called mutable. If the value cannot change, the object is called immutable. Lists and dictionaries are mutable. Numbers, strings, and tuples are immutable. When you change the value of a variable assigned to an immutable object, you are actually creating a new object in memory with the new value, rather than modifying the original object.
Operator
Special symbols that carry out arithmetic and logical computations on values and variables (operands.)
    Arithmetic Operator
    Symbols used to perform mathematical operations. Includes addition, subtraction, multiplication, division, modulus, exponentiation, and floor division. (+, -, *, /, %, **, //)
    Comparison Operator
    Symbols which compare their operands and return either True or False (includes ==, !=, >, <, >=, and <=). Also called “relational operator.”
    Logical Operator
    Keywords used on conditional statements and returns either True or False (includes and, or, and not).
    Assignment Operator
    Symbols used to assign values to variables. The simplest is a single equal sign = but also includes incremental operators like += and -=.
Parameter
A name used inside a function to refer to the value passed as an argument. When the function is called, the arguments in the call are substituted for the parameters.
Print
To display a value to the console / terminal / std out.
Program
A set of instructions that specifies a computation.
Recursion
A programming technique in which a function calls itself to solve a problem. Recursion is often used to solve problems that can be broken down into smaller, similar subproblems, such as searching a tree or sorting a list.
    Base Case
    The condition in a recursive function that stops the recursion. Without a base case, the function will continue to call itself indefinitely, resulting in a stack overflow error.
    Infinite Recursion
    A situation in which a recursive function calls itself indefinitely and resulting in a stack overflow error.
    Recursive Case
    The condition in a recursive function that calls the function again, with a modified version of the original problem. The recursive case is what allows the function to solve the problem by breaking it down into smaller subproblems.
Refactor
To rewrite a program so that it mostly behaves the same way on the outside, but has been internally improved. These improvements can include stability, performance, or reduction in complexity.
Regular Expressions
A pattern that describes a set of strings. Used to search and manipulate text.
Semantics
The intended meaning of a program.
Semantic Error
An error in a program where the code runs without any syntax errors, but the output is not what the programmer intended due to incorrect logic or incorrect use of variables.
Sequence
An order set; that is, a set of values where each value is identified by an integer index. (Strings and lists are examples of sequences.)
Item
One of the values in a sequence. Also called an element.
Index
An integer value used to select an item in a sequence, such as a character in a string.
Slice
A part of a sequence specified by a range of indexes.
Source Code
The code of a program written in a high-level language.
String
A data type representing a sequence of characters.
Syntax
The set of rules (the “grammar”) that defines how a Python program will be written and interpreted.
Syntax Error
An error due to incorrect syntax. Detected while the program is running.
Terminal
Where the output of the program is displayed. Also called the console or visual display.
Tuple
Ordered and immutable data structure (unlike lists and dictionaries, which are mutable.) Created with parentheses. Example:
tuple1 = (3, 4)
tuple2 = (0, 0, 4.9, {dict1})
Type Hinting
A feature introduced in Python 3.5 that allows the programmer to indicate the data types of function arguments, return values, and class attributes. This is done by adding annotations to the code, which can be used by IDEs and static analysis tools to detect errors and provide hints to the programmer.
Value
One of the basic units of data, like a number or a string, that a program manipulates
Variable
A name or label (defined by the programmer) that refers to a value
    Global Variable
    A variable defined outside a function. Global variables can be accessed from any function
    Local Variable
    A variable defined inside a function. A local variable can only be used inside its function.
Version Control
A system that records changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Examples include Git, Mercurial, and Subversion.

Commonly Used Keywords

and
A logical operator that returns True if all statements are true
as
Used to create an alias for a module or import statement
assert
Used to check if a condition is true. If it isn't, the program will raise an AssertionError. Useful for debugging and testing
break
Used to exit a loop prematurely
class
Used to define a new class
continue
Used to skip the current iteration of a loop and continue with the next iteration
def
Used to define a new function
del
Used to delete an object
elif
Short for “else if”. Used to check multiple conditions
else
Used to execute a block of code if the condition is false
except
Used to catch exceptions. Comes after try statement
False
A boolean value that is false
finally
Used to execute code, regardless of the result of the try and except blocks
for
Used to loop through a sequence
from
Used to import specific parts of a module
global
Used to declare a global variable
if
Used to execute a block of code if a condition is true
import
Used to import a module
in
Used to check if a value is present in a sequence
is
Used to test if two variables are the same object
lambda
Used to create an anonymous function
None
A special value that represents the absence of a value
not
A logical operator that returns True if the statement is false
or
A logical operator that returns True if one of the statements is true
pass
A null statement. Used when a statement is required syntactically but you do not want any command or code to execute
raise
Used to raise an exception
return
Used to exit a function and return a value
True
A boolean value that is true
try
Used to test a block of code for errors
while
Used to execute a block of code as long as a condition is true
with
Used to simplify exception handling
yield
Used to pause and resume a generator function

Commonly Used Built-in Functions

abs()
Returns the absolute value of a number
all()
Returns True if all items in an iterable are true
any()
Returns True if any item in an iterable is true
enumerate()
Returns an enumerate object. It contains the index and value of all the items in the iterable as pairs
float()
make a float out of a string or number and return it. If no argument is given, 0.0 is returned.
input()
Accepts input from the user and returns it as a string. Takes an optional argument that will be displayed to user
int()
make an integer out of a string or number and return it. If no argument is given, 0 is returned.
isinstance()
Returns True if the specified object is of the specified type (including subtypes), otherwise False
len()
Returns the length of an an iterable object (number of items in an object)
max()
Returns the largest item in an iterable
min()
Returns the smallest item in an iterable
open()
Opens a file and returns a file object
pow()
Returns the value of x to the power of y
print()
Prints the specified message to the screen, or other standard output device
range()
Returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and stops before a specified number
reversed()
Returns a reversed iterator
round()
Rounds a number to a specified number of decimal places
slice()
Returns a slice sequence
sorted()
Returns a sorted list of the specified iterable object
str()
Returns a string object of passed input
sum()
Returns the sum of all items in an iterable
type()
Returns the type of an argument. Very useful for debugging and testing