Koya University
Faculty of Engineering
Software Engineering Department
Spring Semester - 2026
Chapter 1: Introduction to Programming Concepts
Programming
[KOU20312]
Lecturer:
Kewan S. Saleh
Contact: [Link]@[Link]
Objectives
By the end of this lecture, students will be able to:
• Understand what programming is.
• Explain why programming is important
• Identify basic components of a program.
• Distinguish between programming languages.
• Learn install Python Environment
• Understand Problems solving and Algorithms.
• Apply python programming concepts.
2
Outlines
• Programming Terminologies
• Introduction to programming
• Programming language types
• Setup Environment
• Problem Solving Strategies
• Algorithms
3
Programming Terminologies
• Languages & Code: High-level | Low-level | Source Code
• Tools: Compiler | Interpreter | IDE
• Errors & Debugging: Error | Syntax Error | Runtime Error | Logical
Error | Debugging
• Problem Solving: Problem Solving | Algorithm
4
Questions
• What is programming ?
• Why we use programming?
• Have you heard of Python, Java, or C++? Which one do you think is
easiest for a human to read, and why?
5
What is Computer Programming
Coding [Program]
Programmer Computer
6
Programming
► The term programming means to create (or develop) software, which is also called a program. In
basic terms, software contains instructions that tell a computer—or a computerized device—
what to do.
► Software also plays a role in running airplanes, cars, cell phones, and even toasters.
► If you learn to program using one language, you should find it easy to pick up other languages.
7
Why Learn Programming?
• Problem-solving and logical thinking
• Automation of tasks
• Software and application development
• High demand in the job market
8
Programming in Daily life
9
Programming language types
• Low Level Programming
• High Level programming
10
Low Level programming
• Close to machine hardware
• Difficult to learn
• Example: Assembly language
11
High Level programming
• Closer to human language.
• Easier to read and write.
• Examples: Python, Java, C++, JavaScript
Popular Programming Languages
• Python
• Java
• C / C++
• JavaScript
• PHP
12
Why Python Is Popular (Example)
• Simple syntax
• Widely used
• Large community
• Suitable for beginners
13
Same task with different languages
14
Compiler vs Interpreter
• Compiler: translates whole program
• Interpreter: translates line by line
• Examples:
• Compiled: C, C++, Java
• Interpreted: Python, JavaScript
15
Compiler
• Translates the entire program at once
• Produces an executable file
• Program runs after successful compilation
• Characteristics
• Translation happens before execution
• Errors are reported after compilation
• Faster execution after compilation
• Example Languages
•C
• C++
16
Interpreter
• Translates and executes line by line
• No separate executable file
• Program runs immediately
• Characteristics
• Translation happens during execution
• Stops at the first error
• Slower execution compared to compiled programs
• Example Languages
• Python
• JavaScript
17
Programming vs Coding
• Coding: writing instructions
• Programming: problem solving + design + coding
18
What Is Source Code?
• Code written by programmers
• Human-readable
• Needs translation to machine language
19
What is Programming Error?
• A mistake in a program
• Prevents correct execution
• Common types of Errors
• Syntax errors
• Logical errors
• Runtime errors
20
Syntax Errors
• Breaking language rules
• Detected before execution
21
Logical Errors
• Program runs but gives wrong output
• Harder to detect
22
Runtime Errors
• Occur while the program is running
• Example: division by zero
23
Debugging
• Process of finding and fixing errors.
• Essential programming skill.
24
Programming Mindset
• Think before coding
• Test frequently
• Learn from mistakes
Engineering Thinking
• Understand the problem deeply
• Consider edge cases
• Code is a tool, not the goal
25
Setup Environment
• Windows 11
• Download and Install Python
• Download link for python: [Link]
• Download and install PyCharm IDE
• Download link for PyCharm:
[Link]
• YOUTUBE Video Tutorial:
[Link]
26
Common Student Mistakes
Forgot “Add Python to PATH” (Windows)
Installed PyCharm before Python
Selected wrong interpreter
27
Problems Solving Strategies
• Understand the problem – What needs to be solved?
• Gather information – Collect facts about the problem.
• Choose a method – Decide how to solve it (algorithm/approach).
• Make assumptions – Consider requirements and different cases.
• Solve it – Implement the solution.
• Check results – Test and verify it works correctly.
28
Problem solving -Example
Example: deciding what to wear based on the weather.
• Understand the problem – Choose appropriate clothes for the
day.
• Gather information – Check the weather: rainy, sunny, or cold.
• Choose a method – Pick clothes suitable for the weather.
• Make assumptions – You have clothes for all weather types.
• Solve it – If rainy → wear a raincoat; if sunny → wear light clothes; if
cold → wear a jacket.
• Check results – You feel comfortable and protected from the
weather.
29
Computerizing Problem-Solving
• Define: Understand the problem and the desired outcome.
• Analyze: Check what information you have and the rules to follow.
• Design: Plan the steps to solve the problem (algorithm/flowchart).
• Code: Write the program using a programming language.
• Test: Run the program and fix any errors.
• Maintain: Update and document the program for future use.
30
Algorithm
• An algorithm is a clear step-by-step way to solve a problem. It can
be written in any programming language.
• 5 main features of an algorithm:
• Input – Takes data to work with.
• Output – Gives the result.
• Definiteness & Finiteness – Steps are clear and end in a finite time.
• Effectiveness – Each step is simple and doable.
• Termination – Algorithm eventually stops.
31
Cup of tea algorithm
❑Fill a kettle with water
❑Turn on the kettle
❑Wait until the water boils
❑Put a tea bag into a cup
❑Pour hot water into the cup
❑Add sugar
❑Stir the tea
❑Drink the tea
• Why this is an algorithm?
• Input: Water, tea bag, sugar, milk
• Process: Boiling, pouring, stirring
• Output: A cup of tea
• Clear steps: Each step is simple and well-
defined
32
How to prepare
Kurdish Dolma?
33
Methods for specifying algorithms
There are several common methods to represent the logic of a
program:
• Pseudocode
• A method of describing computer algorithms using a combination of natural
language and programming concepts.
• Focuses on the steps of the solution without worrying about syntax of a
specific programming language.
• Flowcharts
• Use symbols and text to provide a visual representation of a solution.
• Make it easier to understand, analyze, and communicate the algorithm.
• We are mostly focused on Flowcharts.
34
Begin Your Coding Journey
• What is Python
• History Of python
• Why Python?
• Python applications
• Python Code structure
35
What is Python?
• A high-level, interpreted, general-purpose programming language.
• Key Characteristics:
• Readable: Designed to be easy to read and write (looks like English).
• Dynamically Typed: You don't need to declare variable types explicitly.
• Batteries Included: Comes with a massive standard library for almost
any task.
• Multi-paradigm: Supports procedural, object-oriented, and functional
programming.
36
History of Python
• The Creator: Developed by Guido van Rossum in the late 1980s.
• First Release: Python 0.9.0 was released in 1991 at CWI (Netherlands).
• The Name: It isn't named after the snake! It’s named after the British
comedy troupe Monty Python.
• Evolution:
• Python 2.0 (2000): Introduced list comprehensions and garbage collection.
• Python 3.0 (2008): A major overhaul to fix "cruft" (not backward compatible).
• Current Status: Python 3.x is the industry standard; Python 2 was officially
retired in 2020.
37
Why Python?
• Easy to read and write – beginner-friendly
• Large standard library – ready-to-use modules
• Cross-platform – Windows, macOS, Linux
• Versatile – web, desktop, data, AI, automation
• Strong community support – active forums and resources
38
Python Applications
• Web Development – Django, Flask
• Data Science & AI – Pandas, NumPy, TensorFlow
• Automation & Scripting – repetitive task automation
• Game Development – Pygame
• Desktop Applications – Tkinter, PyQt
• Networking & IoT – network apps, hardware projects
39
Python Code Structure
• Modules and Scripts – .py files
• Indentation is Mandatory
• Variables & Data Types – int, float, str, list, dict
• Functions – defined with def
• Control Statements – if, for, while, try/except
• Comments – # for single line, ''' ''' for multi-line
40
PEP 20
• EP 20 – The Zen of Python
• PEP: Python Enhancement Proposal – a design guideline for
Python.
• PEP 20 introduces The Zen of Python – guiding principles for
writing clean, readable, and Pythonic code.
• Written by Tim Peters.
• Access in Python shell:
• import this
• Encourages clarity, simplicity, and elegance in code.
41
Setting Up Your Project
• Before you can write code, you need a "container" for your files.
PyCharm makes this easy by managing your environment for you.
• Open PyCharm: Click on "New Project" from the welcome screen.
• Configure Settings:
• Location: Choose where you want to save your work (e.g.,
C:\Users\Name\PycharmProjects\MyFirstProject).
• Interpreter: Ensure "New Virtualenv environment" is selected. This keeps
your project's libraries organized and separate from others.
• Finalize: Click the Create button at the bottom right. PyCharm will
take a moment to set up the virtual environment.
42
Setting Up Your Project
43
First Hello World code
44
print("Hello, World!")
Special characters
characters with special meaning in strings or code, used for
formatting, escaping, or control.
Sequence Result Description
\n New Line Moves the cursor to the next line.
\t Tab Inserts a horizontal tab (indent).
\\ Backslash Prints a literal backslash.
\' Single Quote Allows a single quote inside a single-quoted string.
\" Double Quote Allows a double quote inside a double-quoted string.
\b Backspace Removes the character before it.
45
Variables (The Storage)
• Variables store data so you can use it later.
• No Declaration Needed: Just name it and set it: age = 25.
• Flexible Names: Use letters, numbers, and underscores (but
don't start with a number).
• Easy Updates: You can change a variable's value at any time.
46
The 4 Fundamental data Types
Type Name Purpose Example
String str Textual data enclosed in quotes. "Hello World"
Integer int Whole numbers (positive or negative). 10, -5
Float float Numbers with decimal points. 3.14, 10.0
Boolean bool Logical values (True or False). True, False
How to Check a Type?
You can use the built-in type() function to find out.
Python
# Testing types
x = 10
y = "10"
print(type(x)) # Output: <class 'int'>
print(type(y)) # Output: <class 'str'>
47
Why Types Matter
• Python treats different types with different rules:
• Math: You can multiply an int by a float, but you cannot subtract a
str from an int.
• Storage: Strings are stored as sequences of characters, while
integers are stored as binary numbers.
• Casting: if you want to perform math on a str that looks like a
number, you must cast it to an int.
48
Printing (The Output)
• The print() function is your window into what the code is doing.
• f-strings: The easiest way to mix variables and text: print(f"Age:
{age}").
• Separators: Use sep to change what goes between items:
print("A", "B", sep="-") outputs A-B.
• Endings: Use end to stay on the same line: print("Hi", end=" ").
49
Special Characters (The Formatting)
• Use these inside your strings to control how the text looks.
• \n (New Line): Like hitting the "Enter" key.
• \t (Tab): Indents your text perfectly.
• \" (Quotes): Lets you put "quotes" inside your message without
confusing Python.
# 1. Setting Variables
user_name = "Alex"
level = 10
# 2. Printing with f-strings and Special Characters
# We use \n for a new line and \t for an indent
print(f"Player Stats:\n\tName: {user_name}\n\tLevel:
50 {level}")
Common Variable Errors
• Even simple assignments can fail if the rules aren't followed.
• NameError: Using a variable before you have defined it (e.g.,
calling print(age) when you only defined Age).
• Invalid Names: Starting a variable with a number (e.g., 1score =
10) or using a space (e.g., user name = "Alex").
• Reserved Keywords: Trying to name a variable after a built-in
Python command (e.g., print = 5). This will "break" the print
function!
51
Common Print Errors
• Most printing errors happen when combining different data types.
• TypeError (Concatenation): Trying to add a number to a string
using +.
• Wrong: print("Score: " + 10)
• Right: print(f"Score: {10}") or print("Score: " + str(10))
• SyntaxError (Missing Parentheses): Forgetting the brackets ()
around the print statement (common if you are looking at old
Python 2 code).
• Quotes Mismatch: Opening with a single quote and closing with a
double quote (e.g., 'Hello").
52
Special Character Errors
• Escape sequences can cause unexpected results if misused.
• Invalid Escape: Using a backslash alone at the end of a string will
cause a SyntaxError.
• The "Path" Problem: In Windows file paths, \n or \t might be
triggered accidentally.
• Problem: "C:\users\new_folder" (The \n creates a new line).
• Fix: Use a raw string: r"C:\users\new_folder".
53
Example
• # --- THE WRONG WAY ---
• # 1score = 10 # ERROR: Starts with a number
• # print("Your score is: " + 10) # ERROR: Cannot add string and int
• # --- THE RIGHT WAY ---
• score1 = 10
• # Using an f-string avoids the Type Error!
• print(f"User Report:\n\tStatus:\t\"Active\"\n\tScore:\t{score1}")
54
Comments
• Text in code for humans only
• Ignored by Python when running the program
• Types
• Single-line: # comment
• Multi-line: """ comment """ or multiple #
• Why Use Comments?
• Explain code clearly
• Help others understand your logic
• Debug easily (disable code without deleting)
55
Advantages of Commenting
• Clarity: Code becomes easy to read
• Maintenance: Easier to update old programs
• Organization: Divides code into sections
• Fewer Errors: Helps catch logic mistakes early
Example
# This is a comment – Python ignores it
score = 100 # Starting score
# print(score)
56 # The line above is commented out and will not run
User Input (Making it Interactive)
• Variables are great, but programs usually need data from the user.
• The input() Function: This pauses the program and waits for the
user to type something.
• Always a String: By default, everything a user types is treated as
text.
• Casting: If you need a number, you must "wrap" it in a converter
like int() or float()
# Simple Input Example
user_age = input("Enter your age: ") # Stores as a string
age_as_number = int(user_age) # Converts to a number
57