Programming Basics SS2 Digital Technologies Lesson Note

Download Lesson Note
Lesson Notes

Topic: Programming Basics

When we write a computer program, we are basically giving a “To-Do List” to the computer. However, the computer has a very short memory unless we tell it exactly what to remember and how to remember it.

To manage information, every programming language (whether it’s Python, Java, or C++) uses three main tools: Variables, Data Types, and Operators.

 

Variables: The Digital Storage Box

Think of a Variable as a physical storage box in the computer’s memory.

If you are moving house, you don’t just throw everything into a truck. You put things in boxes and write labels on them like “Books,” “Kitchen Utensils,” or “Clothes.”

In programming:

  • The Box is the memory space.
  • The Label is the Variable Name.
  • The Stuff Inside is the Data (Value).

Rules for naming your “Boxes”:

  1. No Spaces: Use student_name, not student name.
  2. Start with Letters: You can’t start a name with a number.
  3. Be Descriptive: Name your variable price, not just p, so you remember what it’s for!

 

Data Types: What Kind of “Stuff” is it?

A computer needs to know what is inside the box so it knows what to do with it. You can’t perform math on a word, and you can’t capitalize a number.

Here are the four “Major Flavors” of data:

Data Type Human Name What it is Example
Integer (int) Whole Number Numbers without decimals. 10, -5, 2026
Float Decimal Numbers with points. 10.5, 0.99, 3.14
String (str) Text Letters, words, or symbols in “quotes”. “Hello”, “SS2”, “123”
Boolean (bool) Logical Only two options: Yes or No. True, False

Teacher’s Note: Notice that “123” is a String, not a number. Because it has quotes, the computer treats it like a word. You can’t add “123” + 7—it would cause an error!

 

Operators: The “Action” Symbols

Operators are symbols that tell the computer to perform a specific task. They are the “verbs” of programming.

  1. Arithmetic Operators (The Math Guys)
  • + (Add): 10 + 5 → 15
  • (Subtract): 10 – 5 → 5
  • * (Multiply): 10 * 5 → 50
  • / (Divide): 10 / 2 → 5.0
  1. Assignment Operator (The “Put in Box” Guy)

The = sign is the most used symbol. It doesn’t mean “equals” in the math sense; it means “Assign.”

  • age = 16 (Take the number 16 and put it in the box labeled ‘age’).
  1. Comparison Operators (The Decision Guys)

These are used to compare two boxes. The answer is always True or False.

  • == (Equal to): Is 5==5? True.
  • != (Not Equal to): Is 5!=3? True.
  • > and < (Greater/Less than).

 

Putting it All Together (The Code Example)

Here is how these three things look when they work together in a simple Python script:

Python

# 1. We create variables (boxes)

item_name = “Indomie”      # This is a String

price = 250                # This is an Integer

quantity = 3               # This is an Integer

 

# 2. We use operators to do math

total_cost = price * quantity

 

# 3. We show the result

print(item_name)

print(total_cost)

 

Summary & Recap

  • Variables are names for memory locations (Labels on boxes).
  • Data Types tell the computer if the data is a number, text, or a logic choice.
  • Operators allow us to manipulate that data (Add, Compare, Assign).

 

Class Work / Practical

  1. Identify the data type for the following: 30.0, “Computer”, 45, True.
  2. Write a simple “formula” using variables to calculate the area of a rectangle (Area = Length × Width).
  3. Discussion: Why do you think it’s important to tell the computer the difference between an Integer and a String?

Lesson Notes for Other Classes