Loading...
Increase Font Size
Reduce Font Size
High Contrast
Grayscale
Light Background
Reset
BAITHEI

Foundations of Computer Programming

|
Play Audio
|
Download content: /

Turn on subtitles and choose any language you want.

At the end of this module, you will be able to:

  • Explain fundamental programming concepts such as variables, data types, control structures, functions, and basic algorithms.
  • Apply computational thinking to break problems into smaller parts and design logical, step-by-step solutions.
  • Create small working software projects that demonstrate understanding of core concepts.
  • Demonstrate understanding how software works and how programming concepts apply to practical problems.

Introduction to Programming & Tools

0%
Introduction

This module introduces the foundations of programming and the role of software in modern digital environments. Students learn what programming is, how computer programs operate, and how software interacts with data and hardware. The module also develops computational thinking skills by exploring algorithms, logical problem-solving, and step-by-step reasoning.

Students become familiar with essential programming tools, including code editors, IDEs, and notebook environments. They also learn to use AI tools to support their learning process. AI tools are used to clarify concepts, explain code, identify errors, and provide examples, but students are encouraged to maintain ownership of their work by analyzing AI suggestions critically and practicing writing code independently.

Potential AI applications (ChatGPT, Microsoft Copilot, Google Gemini).

What is programming and how software works?

Activity 1: Explore “What Is Programming?” Through Real Examples

Description: Students review 3–5 everyday software examples and discuss what problems they solve and how code enables them.

AI Support: Students ask AI to explain one chosen app “behind the scenes” and compare it with their own understanding.

Outcome: Students connect programming to real-life software. Findings are discussed together with the instructor.

Model Prompt:

“Explain how [selected app] works behind the scenes at a beginner level.
Describe the problem it solves, the type of data it uses, the logical steps the software follows, and which basic programming concepts are used. Keep it simple.”

 

Activity 2: Explain It Back

Description: Choose 1 example from Activity 1. Write: problem inputs/data  logic steps 3 programming concepts (e.g., variables, if/else, loops, functions).

Outcome: Students show they can describe “behind the scenes” logic and identify basic programming concepts from real software.

Algorithms and computational thinking

Activity 1: Algorithm Design Challenge (Unplugged)

Description: Small groups design simple algorithms without coding.

“Write instructions for making a sandwich”

“Create step-by-step rules for sorting 5 items”

“Explain how to find the biggest number in a list”

AI Support: Students use an AI tool to improve or check their algorithms, then compare AI improvements with their own ideas.

Outcome: Students practice computational thinking and logical structuring before writing real code.

Responses are discussed together and findings compared under guidance of the instructor.

Model Prompt

“Here is the step-by-step algorithm I designed for the task:

[insert your algorithm/task description here]
Please review it and:

  1. Identify any unclear, missing, or ambiguous steps.
  2. Suggest improvements to make the algorithm more precise and logical.
  3. Rewrite the algorithm in a clearer structure without changing its purpose.
  4. Explain why your improvements make the algorithm easier for a computer to follow.“

 

Activity 2: Debug & Optimize (Unplugged)

Description: Groups swap algorithms from Activity 1. One group “runs” the other’s steps exactly and marks where it fails (missing info, ambiguity, wrong order). Then they revise the algorithm to be clearer and shorter, and re-test.

Outcome: Students can identify logic errors/edge cases and refine algorithms into precise, testable steps (intro to debugging optimization).

Programming tools (IDE, notebook, editor)

Activity 1: Introduction to Notebook / IDE Tools

Description: Students open a notebook (e.g., Jupyter, Colab) or a code editor (e.g., VS Code) and perform a guided tutorial:

  • Running their first code cell
  • Adding text notes
  • Creating comments
  • Saving and downloading their work

AI Support: Students ask an AI tool to explain any error message they encounter in the notebook or IDE.

Outcome: Students gain confidence using programming tools and understanding outputs and errors.

Model Prompt

“I am learning to use a programming tool (e.g., Jupyter Notebook, Google Colab, VS Code).
Here is what I am trying to do: [INSERT YOUR TASK]
(e.g., run my first code cell, add a text note, fix an error message)

Please help me by explaining:

  • The correct steps to complete this task.
  • What I should see if everything works correctly.
  • What common mistakes beginners make in this situation.
  • If I have an error, what the error message likely means and how to fix it.
  • Explain everything at a beginner level.”

Variables, Datatypes & Expressions

0%
Introduction

This module moves from theory to hands-on coding. Students learn variables and core data types (int, str, float, bool), use mathematical/logical operators, and practice basic input/output. They also learn to spot and fix common syntax and type errors. By the end, they can write their first interactive scripts.

Potential AI applications (ChatGPT, Microsoft Copilot, Google Gemini).

Variables and datatypes

Activity 1: The "Data Container" Concept (Variables & Types)

Description: Students are introduced to the concept of variables as "labeled boxes" that hold specific types of content. They practice declaring variables for real-world attributes (e.g., name, height) and identifying attributes (String, Integer, Float, Boolean).

AI Support: Students provide a list of real-world items to the AI and ask it to categorize them into the correct programming data types and suggest valid variable names.

Outcome: Students understand how to store data and distinguish between text, whole numbers, decimals, and logic states.

Model Prompt:
“I am learning programming variables. I have the following list of real-world data points:

  • The price of a coffee
  • The number of students in a class
  • Whether a light switch is on or off

For each item, tell me:

  • The best data type to use (Integer, String, Float, or Boolean).
  • A good, descriptive variable name (following standard naming conventions like snake case or camelCase).
  • An example line of code assigning a value to that variable."

 

Activity 2: Type Sort

Description: Make 4 lists titled String / Integer / Float / Boolean. Place these into the right list: "Amanda", 19, 1.72, true, 3.5, 250, 21.0, false. Add one variable name for each list.

Outcome: Students can classify values by data type and propose sensible variable names.

Basic operators

Activity 1: The Calculation Lab (Operators)

Description: Students write and predict simple expressions using arithmetic operators and string concatenation, focusing on edge cases (e.g., string int vs int int) before running code.

AI Support: Students ask AI for operator-precedence practice problems and brief explanations for results (e.g., why 10 / 3 returns a float).

Outcome: Students can manipulate data mathematically and combine text strings effectively.

Model Prompt:

"Create 5 simple coding math problems using basic operators ( , -, *, /, %).

Include one 'trick' question involving string concatenation (e.g., adding "5" "5").

Do not give me the answers yet. Let me guess the output first, then I will ask you to check my work and explain the logic."

 

Activity 2: Fix-It

Description: Students use AI to generate 5 incorrect Python expressions, each paired with a target output. Their task is to edit each expression so that it produces the correct result. They may need to change operator order with parentheses, use % or //, or apply type conversion such as str() or int()..

Example: Target output: 20. Wrong expression: 2 3 * 4. Fixed expression: (2 3) * 4

AI Support: Students ask AI to create simple “Fix-It” challenges without giving the answers. After students submit their corrected expressions, they can ask AI to check their work and explain the logic for each solution.

Outcome: Students can identify and correct mistakes involving operators, precedence, division, modulo, and type conversion.

Outcome: Students can correct operator/precedence/type mistakes to get the intended result.

Model Prompt: “Create 5 beginner-friendly Python Fix-It problems. For each one, show: the target output, one incorrect Python expression. My task is to change the expression so it matches the target output.
Use only simple beginner topics such as basic operators, parentheses, %, //, strings, and simple type conversion.
Do not give the answers yet. After I send my corrected expressions, check them and explain the logic clearly.”

Input/Output

Activity 1: Interactive Scripts (Input/Output)

Description: Students write a script that pauses for user input, saves answers in variables, then prints a formatted output message.

AI Support: Students draft the input prompts and use AI to suggest cleaner/professional output formatting (f-strings or .format()).

Outcome: Students understand the flow of data from the user -> program memory -> screen display.

Model Prompt:
 “I’m writing a program that asks for the user’s favorite movie and its release year.

  • Show the basic command to get user input.
  • Show how to print: ‘Wow, [Movie] was a great hit in [Year]!’ using f-strings or .format().”

 

Activity 2: I/O Check (2 Inputs -> 1 Output)

Description: Extend your script: ask 2 questions, store both answers, then print one formatted line (use an f-string). Optional: use AI to improve wording/format.

Outcome: Students can capture multiple inputs, store them in variables, and produce a clean formatted output.

S1mple error types

Activity 1: The Bug Hunt (Simple Error Types)

Description: Students are provided with code snippets containing intentional errors common to beginners (e.g., NameError for typos, TypeError for adding text to math, SyntaxError for missing parentheses). They must identify the error type and fix it.

AI Support: Students copy the error message received from their IDE and paste it into the AI tool to translate the technical error message into plain English.

Outcome: Students develop resilience and debugging skills, learning that errors are clues rather than failures.

Model Prompt:

"I tried to run my code and got this error message: TypeError: can only concatenate str (not "int") to str

Please explain:

  1. What this error means in simple language.
  2. Why it happened in my code.
  3. How I can fix it (e.g., casting variables)."

 

Activity 2: Bug Report 

Description: Pick 1 bug you fixed. Write a 3-line “bug report”: error type what caused it your fix. Use AI to rewrite your explanation in simpler words (keep meaning).

Outcome: Students can explain common errors clearly and show they understand cause → fix (not just guess-and-check).

Writing First Small Programs

Activity 1: “Ask AI” Code Exploration Exercise

Description: Students prompt an AI assistant to generate a very simple code example (e.g., printing text, using variables). They analyze:

  • What the code does
  • Why it works
  • Whether the AI explanation is accurate

Then they rewrite the code in their own words.

AI Support: AI acts as a learning helper, not a code generator to copy. The focus is on interpreting and explaining code.

Outcome: Students practice reading and understanding code while learning to use AI tools responsibly and critically.

Model Prompt

“Give me a short, beginner-friendly code example about [topic]. Explain what it does step-by-step, why each line matters, and how one small change would affect the result. Mention common beginner mistakes, then give me a simple modification challenge.”

 

Activity 2: Creating a Unit Converter

Description: Integrating all previous sections, students write a small program.

  • Task: Create a simple converter (e.g., Celsius to Fahrenheit, Kilometers to Miles, or Euro to USD).
  • Steps: Get user input -> Convert input to number ->Apply math formula -> Print result.

AI Support: After drafting, students ask AI to check readability and bugs (no rewriting).

Outcome: Students create a working software artifact that solves a specific calculation problem.

Model Prompt:

“Here’s my Python Celsius→Fahrenheit script:
 [INSERT CODE]
 Review it like a tutor—don’t rewrite it.

  • Will it run?
  • Did I convert input from string to number?
  • One small variable-name improvement?”

Control Structures & Logic

0%
Introduction

This module introduces the "brain" of computer programs. Students learn how to make their code make decisions using conditional statements (if/else) and how to automate repetitive tasks using loops (for, while). The module emphasizes understanding program flow—the specific order in which a computer executes instructions.

Potential AI Applications: ChatGPT, Microsoft Copilot, Google Gemini.

Conditionals (if/else)

Activity 1: The Decision Maker (Conditionals)

Description: Students learn decision-making with True/False conditions by writing an if/elif/else script (e.g., grade or age) that prints different outputs.

AI Support: Students give real-world rules and ask AI to turn them into simple pseudo-code or a flowchart outline before coding.

Outcome: Students understand how programs choose different execution paths based on data.

Model Prompt:
 “I’m writing a program that labels a number as Positive, Negative, or Zero.

  • Explain the logic in simple If/Then sentences.
  • Show the basic if/elif/else structure in [Language].
  • Give one example where elif is needed (not just else).”

 

Activity 2: Edge-Cases

Description: Improve your decision-maker to handle boundary inputs (e.g., 0, -1, 1, invalid input). Use AI to suggest 3 edge cases, then update your if/elif/else and re-test.

Outcome: Students can refine conditionals to cover edge cases and prevent wrong paths.

Loops (for, while)

Activity 1: The Repetition Engine (Loops)

Description: Students learn to automate repetitive tasks. They compare the two main types of loops:

  • For Loops: iterating over a fixed list of items (e.g., printing every name in a class list).
  • While Loops: running as long as a condition is true (e.g., a "guess the number" game that keeps asking until the user guesses correctly).

AI Support: Students write a loop that contains a bug (e.g., an infinite loop or an "off-by-one" error) and ask the AI to identify why it doesn't work.

Outcome: Students can implement iteration to process data collections or repeat actions efficiently.

Model Prompt:

"I am confused about when to use a 'for loop' versus a 'while loop'.

  1. Give me a real-world analogy for each (like counting items vs. waiting for a bus).
  2. Write a simple code example that counts from 1 to 10 using a 'for loop'.

 

Activity 2: Convert the Loop

Description: Take one loop from Activity 1 and rewrite it using the other loop type (for ↔ while). Keep the same behavior/output. Use AI to check if your converted version matches.

Model prompt: “Here is my original loop: [paste original code here]
Here is my converted loop: [paste my rewritten code here]
Check whether my converted loop has the same behavior and output as the original.
Tell me if it is correct or not.

If it is not correct, explain what is different.
Give hints about what I should fix.
Only show a corrected full version if I ask for it.”

Outcome: Students can choose between for and while and translate logic between them without changing results.

Program Flow

Activity 1: Visualizing Program Flow

Description: Students trace code with loops conditionals by hand, predicting the next executed line each step to visualize non-linear flow (looping back, skipping if blocks).

AI Support: Students paste code into AI and ask for a step-by-step dry run showing variable values at each step.

Outcome: Students gain a mental model of how the computer reads and executes code line-by-line, including jumps and skips.

Model Prompt:

"Here is a code snippet with a loop and an if-statement inside it: [INSERT CODE]
Please act as a 'code tracer'. Walk me through the execution line-by-line. For every step, tell me:

  1. Which line number is executing.
  2. What the current values of the variables are.
  3. Why the computer decided to go to the next line (e.g., 'because x < 5 is True')."
 

Activity 2: Predict the Output

Description: Take your traced code and create 3 test inputs/starting values. For each, write the exact output before running. Then run (or AI-trace) and correct any wrong prediction with a 1-line note (“I forgot the loop repeats / the if skipped”).

Outcome: Students can predict execution flow and output across different cases, not just follow steps once.

Algorithmic problem-solving

Activity 1: The Logic Puzzle Challenge

Description: Students apply their knowledge to solve a classic algorithmic problem, such as "FizzBuzz" (print numbers 1-100, replacing multiples of 3 with "Fizz" and 5 with "Buzz") or finding the largest number in a list without using built-in functions.

AI Support: AI acts as a "hint giver." If students get stuck on the logic, they ask the AI for a hint about the next logical step, rather than the full solution.

Outcome: Students transition from understanding syntax to solving logic puzzles, a core skill in computational thinking.

Model Prompt:

"I am trying to solve the 'Find the Maximum Number' problem using a loop.

I have a list of numbers: [3, 1, 4, 1, 5, 9]. I know I need to look at each number, but I don't know how to keep track of the biggest one I've seen so far.

Without writing the code for me, can you explain the algorithm or strategy I should use to solve this? Give me a step-by-step plan in plain English."

 

Activity 2: Add a Twist

Description: Take your Activity 1 solution and extend it with one extra rule. Examples:

  • FizzBuzz : also print “Bazz” for multiples of 7 (combine words if multiple rules match).
  • Max : ignore negative numbers (or find both max and min in one loop).

Use AI for one hint only if stuck.

Outcome: Students can adapt an algorithm to new requirements and handle multiple conditions without starting over.

Functions, Modularity & Basic Algorithms

0%
Introduction

This module moves students from writing linear scripts to creating structured, reusable software. Students learn to encapsulate code into functions to avoid repetition (the DRY principle). They explore how to pass data into functions (parameters) and get results back (return values). The module covers how to organize code into logical blocks and introduces fundamental algorithms for searching and sorting data, focusing on the logic behind efficiency.

Potential AI Applications: ChatGPT, Microsoft Copilot, Google Gemini.

Algorithmic problem-solving

Activity 1: The "DRY" Challenge (Defining Functions)

Description: Students are presented with a "messy" script that repeats the same block of code three times (e.g., printing a welcome banner or calculating a tax). They must identify the repeating pattern and "refactor" the code by defining a single function, then calling it three times.

EXAMPLE:
print("********************")

print("*   WELCOME!       *")

print("*  Python Basics   *")

print("*   Let's Begin!   *")

print("********************")

print("Now starting lesson 1...\n")

print("********************")

print("*   WELCOME!       *")

print("*  Python Basics   *")

print("*   Let's Begin!   *")

print("********************")

print("Now starting lesson 2...\n")

print("********************")

print("*   WELCOME!       *")

print("*  Python Basics   *")

print("*   Let's Begin!   *")

print("********************")

print("Now starting lesson 3...\n")

 

AI Support: Students paste the repetitive code into the AI and ask it to identify the redundancy and suggest a function definition to clean it up.

Outcome: Students understand the "Don't Repeat Yourself" (DRY) principle and how to define custom commands.

Model Prompt:

"I have a piece of code that repeats the same 5 lines several times. [INSERT CODE SNIPPET]

  1. Please show me how to turn those 5 lines into a single function named print_banner().
  2. Show me how to call that function so the program does the exact same thing as before, but with less code."
Parameters & Return values

Activity 1: The Black Box Experiment

Description: Students write a “calculator” function that takes two numbers (parameters) and returns a result, learning the key difference between print() (display) and return (send data back).

AI Support: Students ask AI to explain print vs return using a simple real-world analogy.

Outcome: Students can build functions that process data and hand results to the rest of the program.

Model Prompt:

"I am confused about the difference between print() and return inside a function.

  1. Create a simple function called add_numbers(a, b) that uses print.
  2. Create the same function that uses return.
  3. Explain why I cannot use the result of the print version in a math equation, but I can use the result of the return version."

 

Activity 2: The Value Catch

Task: Use the return value of your add_numbers function as an input for a new math problem (e.g., total = add_numbers(5, 5) * 2) and print the final result.

Outcome: Students demonstrate they can "catch" a function's output to use in other parts of their program.

Modularity and code organization

Activity 1: The Library Builder

Description: Students learn they don’t need to code everything from scratch: they practice importing modules (e.g., random, math) and organizing their own code by putting custom functions at the top, separating definitions from execution.

AI Support: Students ask AI to list the "top 5 most useful built-in libraries" for beginners and request a one-line example for each.

Outcome: Students learn to leverage existing code and structure their own files logically.

Model Prompt:

"I want to use code that others have already written.

  1. Explain what an 'import' statement does in [Language, e.g., Python].
  2. Show me how to import the random module.

Write a small script that uses a function from random to pick a winner from a list of names."

 

Activity 2: Math Plugin

Task: Ask the AI for a simple code snippet using the math library (like calculating a square root). Add it to your script, ensuring the import line is placed at the very top.

AI Support (Model Prompt): I am practicing Python libraries.

Please write a small script that:

  1. Imports the math library at the top.
  2. Calculates the square root of 81.
  3. Prints the answer clearly.
  4. Explains what each line does in simple language.

Outcome: Students prove they can independently integrate a new library while maintaining correct code structure.

Simple algorithms (search, sort)

Activity 1: The Guessing Game Logic (Intro to Algorithms)

Description: Instead of writing complex sorting code immediately, students play a "Guess the Number" game (1-100) to understand Linear Search vs. Binary Search.

  • Linear: Guessing 1, 2, 3... (takes up to 100 tries).
  • Binary: Guessing 50, then 25 or 75... (takes max 7 tries). Students write out the logic (pseudocode) for how they would find a number in a sorted list.

AI Support: Students ask the AI to simulate a search algorithm. The student picks a number, and the AI tries to guess it using the most efficient strategy, explaining its logic at every step.

Outcome: Students grasp the concept of algorithmic efficiency (Big O notation concepts).

Model Prompt:

"I want to understand how computers search for data.

  1. Explain the difference between 'Linear Search' and 'Binary Search' using a phone book analogy.
  2. Why is Binary Search faster, but requires the data to be sorted first?

Generate a very simple code example that finds if the number '7' exists in a list [1, 3, 7, 9, 12]."

 

Activity 2: The Sorting Trap

Task: Prompt the AI to run Binary Search on an unsorted list (e.g., [9, 3, 12, 1, 7]) to watch it fail. Then, ask the AI to sort the list and re-run the search.

AI Support: “Use Binary Search to look for 7 in [9, 3, 12, 1, 7].
Show the steps and explain why it fails on an unsorted list.

Then sort the list and do Binary Search again, showing why it works after sorting.”

Outcome: Students learn why Binary Search strictly requires pre-sorted data to function correctly.

Get AI summary

This introductory course develops a solid foundation in computer programming through variables, data types, control structures, functions and basic algorithms. Learners practise computational thinking and problem-solving while using AI responsibly as a learning assistant.

The course comprises four didactic units: Introduction to Programming & Tools; Variables, Datatypes & Expressions; Control Structures & Logic; and Functions, Modularity & Basic Algorithms. Each unit combines explanations with hands-on coding, debugging challenges, AI-supported learning activities and practical mini-projects, followed by self-assessment.

Keywords:

Coding Basics, Computational Thinking, Algorithmic basics, Problem Solving, Program Structures, Program Design, LLM Gen AI, Blended Lesson.

Objectives / Learning outcomes:

The objectives and goals of this training are:

  • Understand fundamental programming concepts such as variables, data types, control structures, functions, and basic algorithms.
  • Apply computational thinking to analyze problems and design simple, logical solutions.
  • Promote digital literacy and empower students to understand how software works.
  • Build a strong foundation in programming for students with little or no prior experience.

Translate this content in other languages

Do you need to translate this content in other languages?

Memo AI

My highlights

Partners