Glossary
Boolean Expressions
Expressions that evaluate to either `true` or `false`, often used to control the flow of a program in conditional statements.
Example:
The condition temperature > 75 is a Boolean expression that would be true if the temperature is 80, and false if it's 60.
Conditional Statements
Programming constructs that execute different blocks of code depending on whether a specified condition is true or false.
Example:
An app uses conditional statements to show a 'Welcome back!' message if a user is logged in, otherwise it shows a 'Please log in' prompt.
Control Flow
The order in which individual statements, instructions, or function calls are executed or evaluated in a program.
Example:
In a game, the control flow might determine if a player's character moves left, right, or jumps based on button presses.
Indentation
The use of whitespace (spaces or tabs) at the beginning of a line to define the scope and structure of code blocks, especially in Python.
Example:
In Python, correct indentation is vital; without it, an if statement's code block won't be recognized, leading to errors.
Relational Operator
Symbols used in programming to compare two values and determine the relationship between them, resulting in a Boolean (true/false) outcome.
Example:
In age >= 18, the >= is a relational operator that checks if the age is greater than or equal to 18.
Selection
A control flow structure that allows a program to choose between different paths of execution based on a condition.
Example:
A program uses selection to decide whether to display 'Access Granted' or 'Access Denied' after checking a password.
else statement
A conditional statement that provides an alternative block of code to execute when the condition of the preceding `if` statement is false.
Example:
After an if statement checks if a user is an admin, an else statement would handle what happens if they are not an admin.
if statement
A fundamental conditional statement that executes a block of code only if its specified Boolean condition evaluates to true.
Example:
An if statement might check if score >= 100: to award a bonus point in a game.