Review and Consolidation of Foundational Concepts
From the Trimester one work completion curriculum
Review and Consolidation of Foundational Concepts
TL;DR
This section helps you solidify the core ideas you've already learned. We'll revisit essential concepts to ensure you have a strong base for future topics. Mastering these fundamentals now will make later, more complex material much easier to understand.
1. The Mental Model
Think of this as checking the foundation of a building. We're making sure all the basic bricks are laid correctly and cemented in place. A strong foundation means your entire learning structure will be stable.
2. The Core Material
We're going to quickly run through key ideas from earlier in the trimester. This isn't about learning new things, but about making sure the old things are really stuck in your head. We'll focus on understanding why these concepts are important and how they connect.
Re-visiting Variables and Data Types

Photo by Markus Spiske on Pexels
Remember that variables are like named containers for information. The "data type" just tells you what kind of information is inside – is it a whole number, a word, or a true/false statement? Knowing the type helps you know what you can do with that information.
# Example: Declaring variables with different data types
my_age = 30 # Integer (whole number)
user_name = "Alice" # String (text)
is_student = True # Boolean (True/False)
price = 19.99 # Float (decimal number)
print(f"Name: {user_name}, Age: {my_age}, Student: {is_student}, Price: {price}")
Understanding Basic Control Flow

Photo by Guy Dwelly on Pexels
Control flow is simply the order in which your code runs. The two big ones are if/else statements for making decisions and for or while loops for repeating actions.
graph TD
A["Start Program"] --> B{"Is it raining?"};
B -- "Yes" --> C["Take an umbrella"];
B -- "No" --> D["Leave umbrella"];
C --> E["Go outside"];
D --> E;
E --> F["End Program"];
Functions: Building Blocks of Code

Photo by Markus Spiske on Pexels
Functions are like mini-programs within your main program. They let you group a set of actions together and give it a name. This means you can run that set of actions anytime you want, without writing it out repeatedly, which makes your code cleaner and easier to manage.
# Example: A simple function
def greet_user(name):
"""This function prints a personalized greeting."""
message = f"Hello, {name}! Welcome back."
print(message)
# Calling the function
greet_user("Charlie")
greet_user("Diana")
3. Worked Example
Let's combine these concepts into a small scenario. Imagine you're writing a simple program to check if a user is old enough to enter a website and then greets them.
# 1. Define a variable for the minimum age
MIN_AGE = 18
# 2. Ask the user for their age (input is always a string, so convert to int)
user_input_age = input("Please enter your age: ")
try:
user_age = int(user_input_age)
except ValueError:
print("That's not a valid age. Please enter a number.")
# In a real app, you'd loop or exit here. For this example, we'll just stop.
exit()
# 3. Use an if/else statement to check eligibility
if user_age >= MIN_AGE:
# If eligible, define a greeting function and call it
def welcome_message(name):
return f"Welcome, {name}! Enjoy your time on our site."
user_name = input("Great! What's your name? ")
print(welcome_message(user_name))
else:
print(f"Sorry, you must be at least {MIN_AGE} to enter.")
print("Thank you for visiting.")
In this example:
- MIN_AGE, user_input_age, user_age, and user_name are variables holding different data types (integer, string).
- The try-except block handles potential ValueError if the user doesn't enter a number.
- The if/else statement is our control flow making a decision based on age.
- welcome_message is a function that neatly packages the greeting logic.
4. Key Takeaways
- Variables are named storage locations; data types define the kind of data they hold.
- Control flow (
if/else, loops) determines the order and conditions under which your code executes. - Functions let you organize and reuse blocks of code, making programs more efficient.
- Understanding how these concepts interact is crucial for building functional programs.
- Practice converting data types (like
input()toint()) because it's a common need.
Common Mistakes to Avoid:
- Forgetting to convert input() from a string to a number when you need to do math with it.
- Not understanding when to use a loop versus an if/else statement.
- Writing the same block of code multiple times instead of using a function.
- Getting confused about variable scope (where a variable can be used) – if you define it inside a function, it usually stays there.
5. Now Try It
Spend 15 minutes writing a small program. Ask the user for a number. Then, using an if/else statement, print whether the number is even or odd. If it's even, also print a message using a function you define yourself. If it's odd, print a different message.
What success looks like: Your program correctly identifies even/odd numbers, uses a function for one of the messages, and doesn't crash if someone types in text instead of a number.
Frequently asked about Review and Consolidation of Foundational Concepts
Get the full Trimester one work completion curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Create Free Account