Computer Programming I SS2 Digital Technologies Lesson Note
Download Lesson NoteTopic: Computer Programming I
What is a Program?
Computers are actually quite “stupid.” They cannot think for themselves. If you tell a computer to “make a sandwich,” it won’t know where to start.
A Program is simply a set of very clear, step-by-step instructions that tell a computer exactly what to do. Before we write those instructions in a language like Python or Java, we must first plan them out using Algorithms and Flowcharts.
Algorithms: The “Recipe” for Success
An Algorithm is a step-by-step list of instructions written in plain English to solve a problem.
Think of it as a recipe: If you miss a step in a cake recipe (like forgetting the eggs), the cake fails. If you miss a step in an algorithm, the computer crashes.
Example: Algorithm to Cross a Busy Road
- Walk to the edge of the sidewalk.
- Look to the left.
- Look to the right.
- If a car is coming, wait and go back to Step 2.
- If no car is coming, walk across the road.
Characteristics of a Good Algorithm:
- Precision: Every step is clear.
- Uniqueness: There is no confusion about what to do next.
- Finiteness: It must eventually end (it shouldn’t go on forever).
Flowcharts: The “Map” of Logic
Sometimes, a list of words is hard to follow. A Flowchart is a diagram that uses different shapes to show the “flow” of an algorithm. It’s a visual way to see how a program makes decisions.
The Standard Symbols
In the world of computers, we can’t just use any shape. Each shape has a specific meaning:
| Shape | Name | Purpose |
| Oval | Start/End | Where the program begins and finishes. |
| Parallelogram | Input/Output | Used when you ask the user for data (Input) or show a result (Output). |
| Rectangle | Process | Used for “doing” things (calculations, moving data). |
| Diamond | Decision | Used for “Yes/No” or “True/False” questions. |
| Arrows | Flow Lines | They show which way the logic is moving. |
Drawing a Simple Flowchart
Let’s take our “Crossing the Road” algorithm and turn it into a flowchart.
- We start with an Oval (Start).
- We use a Rectangle to “Look for cars.”
- We use a Diamond to ask: “Is a car coming?”
- If YES, the arrow loops back up to “Wait.”
- If NO, the arrow goes down to “Cross Road.”
- We end with an Oval (Finish).
Logic Gates: The “Switches” of Thinking
At the very basic level, computers think using “ON” and “OFF” (1 and 0). We use Logic Gates to combine these signals.
- AND Gate: Both signals must be “ON” for the result to be “ON.” (e.g., You can only enter the lab if you have a key AND the teacher is present).
- OR Gate: Only one signal needs to be “ON.” (e.g., You can pass the exam if you score high in the Test OR high in the Exam).
- NOT Gate: It flips the signal. If you put in “ON,” you get “OFF.”
Summary for Students
| Tool | Format | Best for… |
| Algorithm | Written List | Planning the steps in plain English. |
| Flowchart | Visual Diagram | Seeing the “big picture” and the decisions. |
| Pseudocode | Half-Code/Half-English | The final step before typing real code. |
Class Practical Activity
- Group Work: On a piece of paper, write an Algorithm for “Withdrawing money from an ATM.” (Don’t forget the PIN check!).
- Individual Task: Draw a Flowchart that asks a user for their age. If they are 18 or older, display “You can Vote.” If they are younger, display “Too Young.”
Challenge: Try to combine two “Decision” diamonds in one flowchart!