Foundational Concepts of Programming
From the CL term 1 summative curriculum
Foundational Concepts of Programming
TL;DR
Programming is about giving computers precise instructions to solve problems. You'll learn to break down problems into steps and represent information using data. Understanding variables, data types, and control flow is key to writing effective code.
1. The Mental Model
Think of programming like writing a recipe. You tell the computer exactly what ingredients (data) it needs and specific, ordered steps (instructions) to follow to achieve a delicious outcome (solution). Every detail matters.
2. The Core Material
Programming boils down to two main things: handling data and giving instructions.
Data: What computers work with

Photo by ThisIsEngineering on Pexels
Computers deal with information. This information is stored in variables, which are like named containers for values. Think of a variable named age holding the number 25.
Different kinds of information need different ways to be stored. These are called data types. Common ones you'll see are:
- Numbers (Integers/Floats): Whole numbers (like
5,-10) are integers. Numbers with decimal points (like3.14,-0.5) are floats. - Text (Strings): Sequences of characters, like names or sentences. These are usually put in quotes, e.g.,
"Hello World!","John Doe". - True/False (Booleans): Used for logic. There are only two possible values:
TrueorFalse.
Here's how you might declare variables in Python:
name = "Alice" # A string
age = 30 # An integer
pi = 3.14159 # A float
is_student = True # A boolean
Instructions: What computers do

Photo by Gustavo Fring on Pexels
Computers follow instructions sequentially. You tell them what to do, step by step. These instructions often involve:
- Operators: Symbols that perform actions on data.
- Arithmetic:
+(add),-(subtract),*(multiply),/(divide) - Comparison:
==(is equal to),!=(is not equal to),<(less than),>(greater than) - Logical:
and,or,not(combine or negate True/False values)
- Arithmetic:
- Control Flow: This determines the order in which your instructions are executed.
Conditional Statements (Decisions)
Sometimes you want to do different things based on whether a condition is true or false. This is where if, elif (else if), and else statements come in.
score = 85
if score >= 90:
print("You got an A!")
elif score >= 80:
print("You got a B!")
else:
print("You need to study more.")
Loops (Repetition)
When you need to repeat a block of code multiple times, you use loops.
- A
forloop repeats for a specific number of times or for each item in a collection. - A
whileloop repeats as long as a certain condition is true.
# For loop example
print("Counting with 'for' loop:")
for i in range(3): # range(3) gives numbers 0, 1, 2
print(f"Count: {i + 1}")
# While loop example
print("Counting with 'while' loop:")
count = 0
while count < 3:
print(f"Count: {count + 1}")
count = count + 1 # Don't forget to change the condition, or it'll loop forever!
Here's how these concepts fit together:
graph TD
A["Start Program"] --> B["Define Variables (Data)"]
B --> C{"Is condition met?"}
C -- Yes --> D["Execute Instructions (e.g., inside 'if' or 'for' loop)"]
C -- No --> E["Skip Instructions / Move On"]
D --> F{"More items/repetitions needed?"}
F -- Yes --> D
F -- No --> G["End Loop/Branch"]
G --> H["Perform Final Actions"]
H --> I["End Program"]
3. Worked Example
Let's write a simple program that asks for your name and age, then tells you if you're old enough to drive (let's say 16).
# 1. Ask for user's name and store it
user_name = input("What's your name? ")
# 2. Ask for user's age and convert it to a number (integer)
# input() always gives back text, so we use int() to change it.
user_age_str = input("How old are you? ")
user_age = int(user_age_str)
# 3. Use a conditional statement to decide what to print
driving_age = 16
if user_age >= driving_age:
print(f"Hello, {user_name}! You are {user_age} years old. You *can* get your driver's license!")
else:
# Calculate how many years until they can drive
years_to_wait = driving_age - user_age
print(f"Hello, {user_name}! You are {user_age} years old. You need to wait {years_to_wait} more years to drive.")
print("Thanks for using the age checker!")
Running this code:\
If you input "Chris" and "14":
What's your name? Chris
How old are you? 14
Hello, Chris! You are 14 years old. You need to wait 2 more years to drive.
Thanks for using the age checker!
If you input "Sarah" and "18":
What's your name? Sarah
How old are you? 18
Hello, Sarah! You are 18 years old. You *can* get your driver's license!
Thanks for using the age checker!
4. Key Takeaways
- Programs are step-by-step instructions for computers.
- Variables are named storage containers for different types of data.
- Common data types include numbers (integers, floats), text (strings), and True/False values (booleans).
- Conditional statements (
if/elif/else) allow your program to make decisions. - Loops (
for/while) let you repeat actions without writing the same code multiple times. - Understanding data and control flow is fundamental to all programming.
Common Mistakes to Avoid:
* Forgetting to convert user input (which is always text) into numbers when you need to do math with it.
* Mixing up == (comparison, "is equal to") with = (assignment, "store this value").
* Creating infinite while loops by not updating the condition that eventually makes the loop stop.
* Not paying attention to spelling or capitalization in variable names; computers are very picky.
5. Now Try It
Write a short Python program that asks you to enter two numbers. Your program should then print their sum, difference, product, and quotient. Make sure to handle the input correctly so you can perform calculations, and display a helpful message for each result.
Success looks like: Your program correctly performs all four arithmetic operations on the numbers you provide and prints output like: "The sum is: 15", "The difference is: 5", etc.
Frequently asked about Foundational Concepts of Programming
Get the full CL term 1 summative curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Create Free Account