LESSON 1: INTRODUCTION TO PYTHON
PROGRAMMING
Candidates should be able to;
1. Describe python programming
2. Write simple python codes/programs
Python programming language is an example of a high level
language. It is a popular programming language that was created by
Guido van Rossum, and released in 1991. Python was designed for
readability, and has some similarities to the English language with
influence from mathematics.
Uses of Python Programming
It is used for:
1. web development (server-side),
2. software development
3. Solving mathematical notations
4. system scripting.
Why Python?
• Python works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc).
• Python has a simple syntax similar to the English language.
• Python has syntax that allows developers to write programs
with fewer lines than some other programming languages.
• Python runs on an interpreter system, meaning that code can
be executed as soon as it is written.
• Python can be treated in a procedural way, an object-oriented
way or a functional way.
Simple Python Codes/Projects
We shall be writing some python codes.
1. Program to display hello world.
#program to display hello world
print("Hello, World!")
The above code will display: Hello World on the
screen.
Note: The first line of code with the hashtag (#) is
used to create comment in python. Comments are not
executed but are used to explain basic concepts of the
programs you are writing.
2. Program to display integers from 1 to 6
#program to display integers from 1 to 6
for i in range(1, 7):
print(i)
The above code will display the numbers below.
1
2
3
4
5
6
7
3. Program to display current age of a person
Example: Amaka was born in 2001. Write a python
code that will display her current age.
Solution: We are going to subtract the year of birth
(2001) from the current year.
#Program to display current age
Print(2025-2001)
4. Program to add two numbers
We are going to create a pythom code that will add
any two numbers
# program to add two numbers
x = input("Type the first number:")
y = input("Type the second number:")
sum = int(x) + int(y)
print("The sum is: ", sum)
CLASS WORK 1
1. Write a python program that will display “I Love My
Parents”.
ASSIGNMENT 1
2. Write a python program that will add three
numbers