You are on page 1of 29

INTRODUCTION TO PYTHON By: Kobina A.

Adu (Ogyam Ye
Berima)

PROGRAMMING Email: pytech.hub@gmail.com


THE COMPUTER &
ALGORITHM
TABLE OF CONTENT
✓ HOW COMPUTER WORKS
Processor, memory and hard disk
✓ COMMAND PROMPT (CMD)
✓ GRAPHIC USER INTERFACE
✓FILE TYPES AND EXTENSIONS
File types, file path, file name
✓ COMPUTER PROGRAMMING
HIGH LEVEL LANGUAGES
PYTHON PROGRAMING
✓COURSE SOFTWARES
python interpreter & VS code
HOW THE COMPUTER WORKS
❖The computer is a complex machine that can perform a series of logical operations
in simple binaries, ones and zeros.
❖We say that the language of the computer is zeros and ones, but it means is the
presence of current, ones and the absence of electric current, zero.
❖Therefore, a 64-bit processor can generate 264 possible combinations of zeros and
ones whiles a 32-bit processor can only generate 232 possible combinations of zeros
and ones. The higher the bit processor the more processing power you have.
❖Moreover, there are generations and core types of processors. We have intel core
i5, core i3, core i7 with their respective generations. The higher the core the better
and faster the processor.
HOW THE COMPUTER WORKS
➢There are 3 main components in your system unit that we would be concerned about are:
➢1. the processor (CPU)
➢2. the memory (RAM)
➢3. hard disk (ROM)
➢The function of the processor is to process or “do” the instructions that it has been given.
➢The function of the memory is to store the data temporarily. There are different kinds of
memory (RAM). An 8 GB RAM means it can store a maximum of 8 GB of temporal data.
➢The function of the hard disk is to permanently store data on your computer for future use.
HOW THE COMPUTER WORKS
✓Let’s assume you open an App like Music player.
✓Then the computer loads all the relevant commands about the Music Player onto the
RAM.
✓The RAM then feeds the processor with the commands one after the other for
execution.
✓The processor (CPU) takes these commands and do as instruct.

64 BIT
RAM HARD DISK
ACTION PROCESSOR
8 GB 500 GB SDD
CORE I5 (CPU)
HOW COMPUTERS WORK
➢Reasons why your PC runs slow
➢1. If your RAM is small then your computer can’t hold a lot of instructions (Apps) at a time,
relatively. Therefore, an 8 GB RAM will perform better because your computer can work
with a maximum of about 8 GB of data at a time. Hence, a 2GB or 4 GB RAM will
perform worse.
➢2. similarly, when your computer is operating on a 64-bit core i7 processor. It would
perform much better than a 64-bit core i5 or less. However, core i5 processor is relatively
fast enough for you to enjoy your computer games and other stuffs.
➢Have you realized that when your computer storage gets full, then your PC begins to run
slow. Imagine you have a 1 TB HDD hard disk that is 98% full and you ask your computer
to play music for you. The computer would have to scoop through about 1 TB of information
to find you the app and music to play. That would take time.
➢NB: 1 TB is approximately 1.0 𝑥 1012 bytes of data.
GRAPHIC USER INTERFACE
(GUI)
➢The graphic user interface (GUI) is what we
commonly use today. In fact, almost all the
applications and operating systems you interact with
are graphical.

➢For GUI, we interact with buttons, widgets, colours,


pictures, icons, drop downs, etc. Graphic interfaces
helps none technical people use the computer with
easy.

➢However, behind the graphics are commands or


codes that gets executed once you interact with
them.
TERMINAL INTERFACE:
COMMAND PROPMTS
➢The command prompt (console/terminal) is a text-based App that
works with only commands.
➢Early development and use of computers were terminal based.
Therefore, only computer literates could make most out of it.
➢We still have console-based application, and they are still in use
today, such as your MoMo prompts.
➢Other examples are
➢Windows power shell
➢GitBash
➢Linux terminal
FILE NAMES, EXTENTIONS AND
PATH
✓Given a file name such as, “my project codes.py”
✓The name “my project codes” is defined by the user and the
“.py” is the file extension. The extension “.py” means the file
is a python file and should be opened with the python
interpreter.

✓File path: is an address that tells the computer the location


of a file or directory.
✓Example: c:\Users\Kanyerer\Desktop\my project code.py
means the file “my project code.py” can be located on the
hard disk drive “C:” then in the subfolder “Users” then in the
subfolder “Kanyerer” then the subfolder “Desktop”.
TERMINAL INTERFACE VS
GRAPHICAL INTERFACE
The video will be made available on YouTube and
our official telegram group.
YouTube Link: https://youtu.be/MofQIRihc5w
WHAT IS THE COURSE ABOUT?
❑In this course, we are going to write instructions for
our computer. Instructions that would be processed
by our computer based on the way we have
programmed it.
❑At the end of this program, you have the basics in
writing python scripts or compile executable files
that would be interpreted by the processor to
perform specific actions.
❑At the end of this course, you would complete the
basics for python programming, and it would be
your choice to decide where to go next from here.
COMPUTER PROGRAMMING
➢I must say this slides in written in English. English, just like any other
language is a human language. Human languages are referred to
as NATURAL LANGUAGES.
➢EXAMPLE: AMA
➢On the other hand, the computer’s language is zeros and ones. It is
called MACHINE LANGUAGE (LOWER LEVEL).
➢EXAMPLE: 01000001 01001101 01000001 (“Ama” written in
machine code based on ASCII)
➢Imagine how painful it would be to write zeros and ones as
instructions to the computer. Not o talk of the possibility of making a
lot of errors.
➢Read more on data representation click here.
AMERICAN
STANDARD CODE
FOR INFORMATION
INTERCHANGE
(ASCII) TABLE
Read more on character encoding: ASCII,
UTF-8, UTF-16, UTF-32, click here
COMPUTER PROGRAMMING
➢The computer scientist have designed a language that is not completely human language
(natural) but also not completely machine or assembly language.
➢These languages are called higher level languages. Examples are python, C++, java, etc.

Natural language (English) Display “Hello” on the computer screen.

Higher level language (Python) print( “Hello” )

Machine language 1011010111001


HIGHER LEVEL LANGUAGES
✓Higher level languages such as python, C++, java, R, e.t.c. can be
classified into two kinds.
✓1. interpreted languages:
Codes written in interpreted languages such as python
needs an interpreter to work. This is the reason why we needed to
download and install python interpreter on the computer first.
✓2. Compiled languages:
Codes written in compiled languages such as C++ can
work directly on your PC or on another PC once it is compiled. A
compiled program is an executable file.
✓ However, you can compile a python script into an executable file. I
would teach you later.
WHY START WITH PYTHON
PROGRAMMING
✓Try to make meaning from the Python code below. Share your
views.
>> age = input(“What is your age: “)
>> age = int(age)
>> if age >= 18:
>> print(“You are allowed to vote.”)
>> else:
>> print(“You are underage. Come back when you
are 18 years old”)
✓Python is easy to read and write. Therefore, it is a good place to
start especially for people with none computer science background.
PYTHON PROGRAMMING
LANGUAGE
➢Python was invented by Guido van Rossum with the
philosophy of emphasizing code readability.
➢It is a multi-purpose language and has a lots of
powerful libraries and applications.
➢It is a good place to start if you completely do not
know anything about computer programming.
➢I hope you stay through out the 3 weeks because
you are going to get transformed. Your peers would
see your wonderful python works and marvel.
Software
developer

Data Data
Engineer scientist

Career PYTHON PROGRAMMING FOR EVERYBODY

Options
DevOps Artificial
Engineer Intelligence
engineer

Web
developer
SOFTWARE FOR THE COURSE
Visit our Telegram page to download and watch videos on
how to install and use the relevant software for the course:
Software for the course:
1. Python interpreter for windows and Mac
2. Visual studio code for windows and Mac
3. Pydriod3 for android phones and Pyto for iPhones

Contact your tutor incase you have challenges with the


installation process.
HOW TO USE THE PYTHON
INTERPRETER
This video will be made available on our YouTube
channel and on our telegram page.
YouTube Link: https://youtu.be/rDo5x1XsS0w
HOW TO USE VISUAL STUDIO
CODE
The video will be made available on YouTube and on
our Telegram page.
YouTube Link: https://youtu.be/NUZHX6JEPL0
ALGORITHM
A computer algorithm is a process or set of rules to be followed in
calculations or other problem-solving operations, especially by a computer.

Writing out your algorithm helps you to plan your code and make it easier
for other developers to replicate your work in different programming
languages or improve upon what you have developed. Algorithms, reduces
errors in the code and makes life simpler.

Algorithms can be represented in the following forms:

➢ pseudocode – a less detailed code that describes an algorithm.

➢Flowchart – the use of diagrams and charts to show the flow of an


algorithm.

➢Essay form – An essay that describes a step-by-step approach to solving a


problem.
FLOWCHART
- For the purposes of this
course, we would focus
more on flow charts.

- There are several flow


chart diagrams that you
must take note of.

- See the diagrams for


their meanings.
Click to read more
EXAMPLE OF AN ALGORITHM
Let us take a quick look at a problem and use the 3 forms
of algorithms to depict how the solution will look like.

QUESTION
Write a simple computer algorithm to that will demonstrate
how your software will take a complex number as an input
from the user and calculate the modulus.

NB: Use draw.io App to draw the flowchart. You can access
draw.io on their website or download and install. Click
here to use draw.io
SOLUTION Step 1
ESSAY FORM
Step1: start program.
Step 2

Step2: Ask the user for input. Example: 3 + 4i


Step 3

Step3: Pick the real part and the imaginary part. Example: real = 3, and img = 4.
Step 4
Step4: calculate the modulus using the formula
𝑧 = 𝑟𝑒𝑎𝑙 2 + 𝑖𝑚𝑔2 = 32 + 42 = 5
Step 5

Step5: Display output. Example: Ans = 5


Step 6
Step6: Stop program.
CONT…
Question
Write a computer algorithm to tell a if the CWA value input into the computer is first class or
not.
Solutions:
Th charts below will be used to construct the flow chart for the question.

Terminal Decision
Process
Use for starting or For making
Use when performing Input / Output
terminating a True/False
an action or process.
program. decisions.
FLOWCHART
Step1: Start program.

Step2: Ask for input. Ex: 79.45

Step3: Make a decision. Condition: CWA >= 70.

Step4: Display First class if condition is met else


display Not first class.

Step5: Stop program.


THANK YOU
YO U H AV E C O M P L E T E D
D AY 0
OF OUR BOOTCAMP

You might also like