Glossary
Algorithm
A set of instructions designed to solve a problem or complete a task, representing the logical steps of a process.
Example:
To make a perfect sandwich, you follow an algorithm: get bread, add filling, then add another slice of bread.
Arithmetic Operators
Symbols used in programming to perform mathematical calculations like addition, subtraction, multiplication, division, and modulo.
Example:
The plus sign + is an arithmetic operator used to add two numbers, like 7 + 3.
Code statements
Individual actions or instructions within a program that serve as the fundamental building blocks of algorithms.
Example:
print("Hello") is a single code statement that tells the computer to display text.
Expression
A combination of values, variables, operators, and functions that evaluates to a single value.
Example:
The calculation (5 * 3) + 2 is an expression that evaluates to 17.
Iteration
A programming construct that allows a set of instructions to be repeated multiple times, often until a certain condition is met.
Example:
A for loop that prints numbers from 1 to 10 demonstrates iteration, repeating the print action for each number.
MOD (Modulo Operator)
An arithmetic operator that calculates the remainder when one number is divided by another.
Example:
10 MOD 3 results in 1, because 10 divided by 3 is 3 with a remainder of MOD 1.
Order of Operations
A set of rules (like PEMDAS/PEMMDAS) that dictates the sequence in which mathematical operations should be performed in an expression to ensure a consistent result.
Example:
In 2 + 3 * 4, multiplication is performed before addition due to the order of operations, resulting in 14, not 20.
Selection
A programming construct that allows an algorithm to make decisions and execute different blocks of code based on certain conditions.
Example:
An if/else statement is a form of selection; if a user's age is less than 18, one message is displayed, otherwise a different one.
Sequencing
The execution of steps in an algorithm in the exact order they are written, from top to bottom.
Example:
In a program, setting x = 5 and then y = x + 2 demonstrates sequencing, as x must be defined before y can be calculated.