Practical Manual For Python 3 Programming
Practical Manual For Python 3 Programming
PROGRAMMING
Prepared by
Akintola Victor (ICT Instructor AFGMS)
PYTHON
Prepared by
Akintola Victor (ICT Instructor AFGMS)
THE WAY OF THE PROGRAM
Thinking like a programmer combines some of the feature of maths,
engineering, and natural science, programmers use formal
language(programming syntax) to denote ideas.
The Single most important skills for a programmer is problem
solving! It means, the intellectual capacity to formulate problems,
think creatively about the solution, and express a solution clearly and
accurately.
A program is a sequence of instructions that specifies how to
perform a computation, it may be mathematical, symbolic, or
graphical. Programming languages are used to express computations.
Computation’s usually entails : input – output – mathematical –
conditional execution, repetition.
PYTHON
Python is an High Level Language created by Van Don Rossum, it is
characterized by its clear and concise code.
Its Applications include Artificial Intelligence (AI), 3D (CAD ,AR, VR),
Desktop Applications, Web Development, Malware Development,
Mobile App Development, among others.
To use python programming language you have to download a
version which is about 25mb from www.python.org. after download
install the software to get started.
To check if python is successfully installed on the OS, open command
prompt (CMD) and type python and a SHELL would be instantiated.
The SHELL is a program that reads and execute python code.
YOUR FIRST PROGRAM
There are three ways to start writing python code; using the CMD,
using the IDLE, and using an IDE (Integrated Development Env.).
print(“Hello World my name is xavier”)
AND OPERATIONS
Prepared by
Akintola Victor (ICT Instructor AFGMS)
OPERATORS
operators
if , elif, else statements
ESCAPE SEQUENCES
2. There are different types of escape sequences including :
# horizontal tab
print("This is an horizontal \t tab")
# vertical tab
print("This is an horizontal \v tab")
NUMERICAL LITERALS
2. You can also perform arithmetic operations with numerical literals.
when a float is added to an integer you get floats
# arithmetic operations
int1 = 20
int2 = 40
truthy = True
falsy = False
# calling functions
greet()
FUNCTIONS
2. A function can be defined with parameters which are going to be
used in the computation.
Parameters are specified placeholders during function definations.
Arguements supply information to the function to use in processing.
# defining a variable
person = "nenret"
add(2,3)
FUNCTIONS
5. A function that calculates the manhattan distance between two
points : point1(lat, long), point2(lat, long).
# 5. A function that calculates manhattan distance between two points
# manhattan distance formula = (x2-x1) + (y2 - y1)
distance(2,5,3,6)
FUNCTIONS
5. A modified version of the function using array data structures for
simplifying computation.
# defining arrays
point1 = [2,5]
point2 = [3,6]