11/13/2024
Chapter One: Introduction (4hrs.) 1.1. Introduction to Programming
Outline: Course Description
1.1. Introduction to Programming This chapter introduces basic concepts of programming and problem-
solving strategies using algorithms, and programming paradigms.
1.2. Problem Solving Techniques
Learning Outcomes
1.2.1. Algorithms Development and Representations
By the end of this unit, students should be able to:
1.2.2. Pseudocode Explain computer programming.
1.2.3. Flowchart Differentiate programming paradigms.
List out properties of algorithms.
Develop an algorithm for a given problem.
Use flowchart and pseudo code to formulate a problem.
1.1. Introduction to Programming 1.1. Introduction to Programming
What is programming? What is programming?
• Computer programming is how people can communicate and interact with • Programming refers to a technological process that tells a computer
computers.
which tasks be performed to solve problems.
• Computer programming refers to using different languages to
communicate with and instruct computers. Programming languages are • You can think of programming as a collaboration between humans
those that computers can read, and there are different languages to and computers, in which humans create instructions for a computer
accomplish different tasks. to follow (code) in a language computers can understand.
• Programming makes it possible to do many of the activities we do each
day, like using our computers or phones and powering the systems that
surround us, such as financial services and banking. Explore more about
computer programming and coding languages below.
11/13/2024
1.1. Introduction to Programming 1.1. Introduction to Programming
• A programming language is a set of instructions and syntax used to create What is programming?
software programs. Some of the key features of programming languages include:
• Syntax: The specific rules and structure used to write code in a programming language.
Programming enables so many things in our lives, such as:
• Data Types: The type of values that can be stored in a program, such as numbers, strings, and • When you browse a website to find information or make a purchase,
booleans. programming allows you to interact with the site’s on-page elements, such
• Variables: Named memory locations that can store values. as sign-up or purchase buttons, contact forms, and drop-down menus.
• Operators: Symbols used to perform operations on values, such as addition, subtraction, and
comparison. • The programming behind apps can make it easy to order food, book a
• Control Structures: Statements used to control the flow of a program, such as if-else rideshare service, track your fitness, access media, and more.
statements, loops, and function calls.
• Libraries and Frameworks: Collections of pre-written code that can be used to perform
• Programming helps businesses operate more efficiently through different
common tasks and speed up development. software for file storage and automation and video conferencing tools to
• Paradigms: The programming style or philosophy used in the language, such as procedural, connect people globally.
object-oriented, or functional.
• Space exploration is made possible through programming.
1.1. Introduction to Programming 1.1. Introduction to Programming
• Is programming hard? • How does computer programming work?
• Much like learning any other language, programming takes effort and • At its most basic, programming tells a computer what to do. Although
consistency. Anecdotally, you may hear that it gets easier to learn there are many different kinds of coding languages, a computer can only
other coding languages once you've mastered your first. speak a single language of machine language or object code. Object code is
written in binary, which is a string of ones and zeros that doesn't look like a
• What’s the difference between coding and programming? language we’d recognize.
• Coding and programming are sometimes used interchangeably, but • Translating code from something humans can read into something
the two concepts are slightly different. Coding refers to the act of computers can depends on two types of programming
writing code, while programming refers to creating a set of languages. With compiled languages, such as C and C++, a compiler
instructions for a computer to follow, or a computer program. translates the code into a machine language. However, interpreted
Programming can include a broader range of tasks, such as working languages, such as Python and JavaScript, execute the code directly.
with data structures and algorithms, that aren’t inherently coding. There's no need for a compiler.
11/13/2024
1.1. Introduction to Programming 1.1. Introduction to Programming
• In short, programming follows a few steps: • Key programming languages
• Different programming languages enable programmers to write code that
• First, a programmer writes code—a set of letters, numbers, and other computers understand. According to a survey by Statista, the top five
characters. programming languages that developers use are:
• Next, a compiler converts each line of code into a language a • C/C++, Java
computer can understand. • JavaScript, used by 62.3 percent
• HTML/CSS, used by 52.9 percent
• Then, the computer scans the code and executes it, thereby
• SQL, used by 51 percent
performing a task or series of tasks.
• Python, used by 51 percent
• Tasks might include displaying an image on a webpage or changing • TypeScript, used by 38.5 percent
the font of a section of text. • Explore next what you can do with these programming languages.
1.1. Introduction to Programming 1.1. Introduction to Programming
• Basic Terminologies in Programming Languages:
Types of computer programming languages (Paradigm) • Algorithm: A step-by-step procedure for solving a problem or performing a task.
• While hundreds of programming languages (if not thousands) exist, • Variable: A named storage location in memory that holds a value or data.
• Data Type: A classification that specifies what type of data a variable can hold, such as integer, string, or boolean.
and you could classify them in many ways, they typically can be • Function: A self-contained block of code that performs a specific task and can be called from other parts of the program.
grouped into five main categories: • Control Flow: The order in which statements are executed in a program, including loops and conditional statements.
• Syntax: The set of rules that govern the structure and format of a programming language.
• Procedural programming languages
• Comment: A piece of text in a program that is ignored by the compiler or interpreter, used to add notes or explanations to the
• Functional programming languages code.
• Debugging: The process of finding and fixing errors or bugs in a program.
• Object-oriented programming languages • IDE: Integrated Development Environment, a software application that provides a comprehensive development environment for
coding, debugging, and testing.
• Scripting languages
• Operator: A symbol or keyword that represents an action or operation to be performed on one or more values or variables, such
• Logic programming languages as + (addition), – (subtraction), * (multiplication), and / (division).
• Statement: A single line or instruction in a program that performs a specific action or operation.
11/13/2024
1.2. Problem Solving Techniques 1.2. Problem Solving Techniques
Here are some problem-solving techniques in programming:
Algorithm Development and Representation
• Understand the problem: Read the problem statement, identify input and output requirements,
and clarify any assumptions or constraints. i. Structured Chart
• Analyze and break down the problem: Figure out how a computer can help with the problem.
• Create an algorithm: Design a step-by-step process to solve in a finite amount of time. ii. Pseudocode
• Implement the algorithm: Put the algorithm into a programming language. iii. Flowchart
• Maintain the program: Keep the program up to date.
• Debug: Use specialized software to run the program and observe errors. Then, use problem-
solving skills to determine the cause of the error.
• Divide and conquer: Break the problem into smaller parts, solve each part individually, and then
combine the solutions to get the overall answer.
• Dynamic programming: Break the problem into subproblems, and use the optimal solution to the
subproblems to find the optimal solution to the larger problem.
Conti… Conti…
• Algorithm: is a set of finite rules to be followed in calculations or Algorithm: Characteristics (properties) of algorithms:
other problem-solving operations using a computer. It is an ordered
set of unambiguous, executable steps.
It has:
• Sequence: Is implied by the ordering of the steps in the algorithm.
• Selection: allows for the selective execution of steps based on some
conditional evaluation.
• Repetition: allows for execution of the same steps repeatedly.
11/13/2024
Conti… Conti…
Algorithm: Characteristics (properties) of algorithms: • Structured Chart
• Represent hierarchical structure of modules. It breaks down the
entire system into lowest functional modules.
Conti… Conti…
Flow chart: Pictorial representation of how to solve a problem. Pseudocode
It is a picture of the separate steps of a process in sequential order. • Implementation of an algorithm of informative/explanatory text written in
English.
• Example:
if "1"
print response
"I am case 1"
if "2"
print response
"I am case 2"
11/13/2024
Examples 1: Examples 2:
• Problem • Problem
• Input the temperature in degrees Celsius • Sketch a flow chart to find area of a circle?
(call it Celsius), Calculate Fahrenheit as • Write a pseudo-code?
(9/5)*celsius+32?
Sketch flow chart and write a
pseudo-code?
Examples 3: Some Terminologies
Problem: • Bug: An error in a program.
Find greater of two numbers? • Debugging: The process of finding and removing any of the three kinds of programming errors.
Sketch flow chart and write the pseudo-code? • Syntax: The structure of a program.
• Syntax error: An error in a program that makes it impossible to parse (and therefore impossible to
interpret).
• Exception: An error that is detected while the program is running.
• Semantics: The meaning of a program.
• Semantic error: An error in a program that makes it do something other than what the
programmer intended.
11/13/2024
Summary Questions
• Payroll System, Ethiopian Employment.
• Design an algorithm to calculate salary for an employee in an
organization.
• Develop an algorithm to compute a student’s grade in a programming
course based on the total score. Thank you!!
• Write an algorithm to enumerate the first N prime numbers.