Module 1: Getting Started with Programming
What is Programming?
What is a Programming Language?
High-Level vs. Low-Level Languages
How Computers Understand Programming Languages (Compilers and Interpreters)
Basic Syntax Rules
How to Write and Run Code (Kaggle Environment)
What is Programming?
Programming is the process of creating a set of instructions that tell a computer how to perform a task.
Think of programming as giving step-by-step directions to a computer, just like you would tell someone how to bake
a cake, play a game, or draw a shape.
🖥Why Do We Need Programming?
Computers are powerful but not intelligent. They don’t know what to do unless we tell them exactly what to do.
Programming allows us to:
Build websites and apps
Control robots and smart devices
Analyze large amounts of data
Create video games, animations, and more
🍰 Real-Life Analogy
Imagine you're teaching someone to bake a cake who has never cooked
before.
You need to give very specific instructions:
1.Take 2 cups of flour
2.Add 1 cup of sugar
3.Mix well
4.Bake for 30 minutes at 180°C
If you say just “make a cake,” they won’t know what to do.
Computers are the same they need exact, clear instructions.
What Does a Program Look Like?
So… What Is Programming Really
A program is just a list of instructions About?
Programming is:
written in a special language called a Problem-solving: You think of a task
programming language. you want to complete.
Planning: You break the task into
Example in Python:
small, logical steps.
python Writing instructions: You write those
print("Hello, world!") steps in a programming language.
Communicating with computers: You
This is a command telling the computer
give the computer a job to do.
to display the message:
👉 “Hello, world!” on the screen.
🛠 What Can You Build with Programming?
With programming, you can create:
💻 Software and desktop apps
📱 Mobile apps
🌐 Websites and online tools
🧠 Artificial Intelligence (AI)
🎮 Games and simulations
📊 Data analysis models
🤖 Robotics and automation systems
💻 What is a Programming Language?
🔍 Definition
A programming language is a special language used to write instructions that a computer can
understand and follow.
It acts like a translator between humans and computers.
Humans speak in natural languages like English, Hindi, or Arabic.
Computers understand only binary (0s and 1s).
So we use programming languages like Python, Java, or C++ to write code in a human-
friendly way and then tools convert that code into something the computer can execute.
💬 Real-Life Analogy
Imagine you're in Japan and want to ask for food. You don’t know Japanese, but
your friend does. You tell your friend in English, and your friend translates it into
Japanese for the chef.
You = Programmer (human)
Friend (translator) = Programming Language
Chef = Computer
The programming language helps you communicate with the computer.
What Does It Look Like?
Human Language:
Show the message "Hello"
Programming Language (Python):
python
print("Hello")
Machine Language (Binary):
01001000 01100101 01101100 01101100 01101111
Without a programming language, you'd have to write
everything in binary which is hard and not practical.
Why Do We Use Programming Languages?
To write programs in a way humans can understand
To avoid writing complex binary code
To develop websites, games, mobile apps, and AI
To save time and reduce mistakes
To make computers useful in solving real-world problems
🛠 Types of Programming Languages
1. High-Level Languages (easy for humans)
Examples: Python, Java, C++, JavaScript
🏫 Simple Example
Human-readable and closer to English Python Code:
python
Needs a compiler or interpreter to run
print("I love coding!")
2. Low-Level Languages (closer to machine) This tells the computer to show:
👉 I love coding!
Examples: Assembly Language, Machine Code You wrote it in Python, the computer
understands it because the language translates it
Harder to read, but runs faster into machine instructions.
Directly communicates with hardware
High-Level vs. Low-Level Programming Languages
🔍 What Are Programming Language Levels?
Programming languages are classified based on how close they are to human language or machine
language. These classifications help us understand the abstraction level at which a language operates.
There are two main categories:
High-Level Languages
Low-Level Languages
Each serves a different purpose, depending on who is writing the code (human vs. machine focus) and
what the code needs to do (general logic vs. hardware control).
💡 1. High-Level Programming Languages
✅ Definition
High-level languages are programming languages designed to be easy for humans to read, write, and
understand. These languages are abstracted from hardware details and are closer to natural human
languages like English.
Examples:
Python
Java
C++
JavaScript
Ruby
⚙️Key Features:
Use Cases:
Readable syntax (like natural language)
Web development
Platform-independent (portable across systems) Mobile apps
Easier debugging and maintenance Artificial Intelligence (AI)
Data Science
Requires a compiler or interpreter to run
Business applications
📌 Code Example (Python):
python
print("Welcome to Programming")
This simple line tells the computer to display a message easy to understand even for
beginners.
🛠2. Low-Level Programming Languages
✅ Definition
A low-level programming language is a type of language that is very close to the computer's hardware. It
provides minimal abstraction, which means it directly controls the internal operations of a computer’s processor
and memory.
Low-level languages are not easy for humans to read or understand, but they are fast and efficient for computers
to execute.
🔍 Types of Low-Level Languages
1. Machine Language Example in Real Life
Written in binary (0s and 1s)
Directly understood by the CPU
Imagine controlling a robot:
Example: High-Level Language: You say “Move
10110000 01100001 forward 10 steps.”
2. Assembly Language Low-Level Language: You manually tell
Uses short English-like words (called mnemonics) the robot:
Easier than binary but still close to machine code • Start motor
Requires an assembler to convert it into machine code • Set speed to 10
• Wait for 5 seconds
Example: • Stop motor
MOV AX, 5
ADD AX, 2
🔁 Code Example Comparison
Task High-Level (Python) Low-Level (Assembly)
MOV AX, 3
Add 2 numbers print(3 + 5)
ADD AX, 5
How Computers Understand Programming
Languages: Compilers and Interpreters
🔍 Overview
Computers, at their most fundamental level, do not understand human-readable programming languages.
Instead, they operate using machine language a set of binary instructions (comprised solely of 0s and 1s)
that a computer's processor can execute directly.
To bridge the gap between high-level human-friendly programming languages (like Python, Java, or C++)
and machine-executable instructions, we use language translators primarily compilers and interpreters.
What is Machine Language?
Machine language is the native language of computers, composed entirely of
binary code. Every command, operation, and data manipulation the computer
performs is ultimately translated into this binary format .
Example
binary
10110000 01100001
Such code is specific to the architecture of the machine (CPU-specific) and is
unintelligible to humans, hence the need for translation mechanisms.
🔄 Translating High-Level Code: The Role of Compilers and Interpreters
High-level source code (e.g., print(“Hello World")) must undergo
translation into machine language before execution. Two primary
translation tools serve this purpose:
🛠 1. Compiler
✅ Definition:
A compiler is a software tool that translates the entire high-level program into machine
code in one go, creating a separate executable file.
How It Works:
Reads the complete source code.
Checks for syntax errors.
Translates the entire code into machine code.
Generates an executable (.exe or binary) file.
Key Characteristics
Feature Description
Translation Performed once, before execution
Execution Speed Fast (after compilation)
Error Handling Displays all errors after full analysis
Examples C, C++, Java (JVM compiles bytecode)
📌 Analogy:
A compiler is like translating a full book into another language, printing it, and then
giving the translated version to the reader.
🛠 2. Interpreter
✅ Definition:
An interpreter is a software tool that translates and executes high-level code line-by-line
without producing a separate executable file.
How It Works:
Reads one line of code.
Translates it to machine code.
Executes it immediately.
Repeats for each line until the program ends.
🔍 Key Characteristics
Feature Description
Translation Performed line-by-line during execution
Execution Speed Slower due to real-time translation
Error Handling Stops at the first error
Examples Python, JavaScript, Ruby
📌 Analogy:
An interpreter is like a live translator who translates each sentence while someone is
speaking.
🔁 Compiler vs. Interpreter: Comparative Table
Feature Compiler Interpreter
Translation Method Full program at once Line-by-line
Speed of Execution Faster (precompiled) Slower (real-time translation)
Reports all errors after
Error Detection Stops at first error
compiling
May use more memory for
Memory Usage Efficient at runtime
long scripts
Generates standalone
Output No executable file created
executable file
Examples C, C++, Go Python, JavaScript, PHP
✍️Basic Syntax Rules in Programming
What is Syntax in Programming?
In programming, syntax refers to the set of rules that define the correct structure and
format of code in a programming language.
Just like every human language (like English or Somali) has grammar rules, every
programming language has its own syntax rules. If you don’t follow them, the computer
will not understand your instructions resulting in syntax errors.
📌 Why is Syntax Important?
Ensures that the program runs correctly
Helps prevent misunderstandings between the programmer and the machine
Maintains readability and consistency in code
Prevents bugs and execution errors
Real-Life Analogy:
Imagine writing a sentence:
Correct: “The cat sits on the table.”
Incorrect: “Cat table the on sits the.”
🔍 Key Syntax Rules (Python as an Example)
Although syntax differs by language, the following are common rules you must follow
(examples in Python):
1. Case Sensitivity
Programming languages often treat uppercase and lowercase letters as different.
Print("Hello") # ❌ Incorrect
print("Hello") # ✅ Correct
2. Use of Parentheses and Quotes
3. Colon and Indentation (Python-specific)
Parentheses are used in function calls
Quotation marks are used for strings Python uses indentation (spacing) to define
code blocks.
print("Hello, world!") # ✅ Correct
if 5 > 3:
print(Hello, world!) # ❌ Error: quotes
print("Five is greater than three") # ✅ Correct
missing
4. Statements Must Follow Specific Order
name = "Alice"
print(name) # ✅ Correct: variable must be defined before use
5. Avoid Special Characters (Unless Allowed)
Don’t use symbols like @, #, & unless the language allows or requires them.
python
a@b = 5 # ❌ Error
a = 5 # ✅ Correct
🔁 Common Syntax Errors to Avoid
Mistake Description
Misspelled keywords Using pritn instead of print
Missing colons (Python) if or for without a colon
Wrong case Using Print instead of print
Starting a string with " but not ending
Unmatched quotes
it
Incorrect indentation Not aligning blocks of code properly
💻 How to Write and Run Code (Kaggle Environment)
🌐 What is Kaggle?
Kaggle is a free, web-based platform provided by Google where students, programmers, and
data scientists can:
Write and run code online (without installing anything)
Access real-world datasets
Build machine learning models
Collaborate with others in the community
Kaggle is especially useful for learning Python programming and data science, and it
provides a built-in environment called a Kaggle Notebook.
Why Use Kaggle for Learning Programming?
Benefit Description
Runs in your web browser (no need to
✅ No installation
install Python)
✅ Easy to use Beginner-friendly interface
✅ Free 100% free to use
Includes Python, libraries (like NumPy,
✅ Built-in tools
Pandas), and GPUs
Your code is saved online and can be
✅ Online saving
accessed from anywhere
📝 What is a Kaggle Notebook?
A Notebook is an online coding workspace where you can:
Write Python code
Add explanations in Markdown (text cells)
Run your code and see the output instantly
Create charts, analyze data, and visualize results
Step-by-Step: How to Write and Run Code on Kaggle
🔹 Step 1: Create an Account
Visit: https://www.kaggle.com
Click on Sign Up (or Log In if you already have an account)
Use your Google account for quick registration
🔹 Step 2: Start a New Notebook
After logging in, click on the “Code” tab in the top navigation bar
Click “New Notebook”
A blank notebook will open where you can write and run your code
🔹 Step 3: Write Python Code
In the grey cell, type your Python code.
Example:
print("Hello, Kaggle!")
🔹 Step 4: Run the Code
Click the ▶️Run button (triangle icon) on the left of the code cell
The output will appear below the code
🔹 Step 5: Save and Rename
Click on the file name (e.g., "Untitled") at the top and give your notebook a name
Click on the Save icon or let Kaggle auto-save your progress
🔹 Step 6 (Optional): Add Text
Click +Text to add instructions or explanations between code cells
This is great for writing notes or creating assignments
✅ Example in Kaggle Notebook
Code Cell:
x=5
y = 10
print("The sum is:", x + y)
Output:
sum is: 15
Examples
Use if to Make a Simple Decision
Combine Words (Strings)
first_name = "John" age = 18
last_name = "Doe" if age >= 18:
print("You are an adult.")
print(first_name + " " + last_name)