Professional Documents
Culture Documents
Lesson 9
Introduction to computer programming
SEDIN
IT Education Services Center
2
Today
Second
partial
3
What is programming?
• It is basically teaching a machine how to perform a certain task
or solve a certain problem (may it be simple or very complex)
Requisites Analysis
Design
Implementation
Algorithms
An algorithm is a process that allows the user to solve a problem through a
finite number of simple steps. Example: cake recipe
Beginning
• Sugar + Eggs
• Weigh the ingredients • Add flour
Ingredients
• Add butter
• Mix the ingredients • Add baking soda
Top-down approach:
from general to specific actions
8
Implementing an algorithm
Start
(click of a button)
Use Scratch to implement the algorithm
Say “Hello!”
Step forward
Make a sound
Repeat
Step back
10 times
Make a sound
Say “Yeah!”
End
9
BUS
CPU and memory can only perform very simple operations, managing data in machine
language. Data are represented with Binary Notation. e.g.:
Machine language
• In the Fifties, programs were all written with 0 and 1
• Instructions were long sequences of bits (binary digits) and corresponded
to very simple actions
Programming languages
• A programming language is an interface for giving a computer the
instructions needed to solve a problem
Examples
Software for self-driving cars
100M LOCs
Google services
2B LOCs
14
Import of the
needed module
Input
coefficients
Compute
discriminant
Compute solutions
Show output
End
15
Assembly
Machine
Language
16
What is Python
• Python is a high-level interpreted, interactive, object-oriented programming
language
• It was conceived by Guido Van Rossum in 1989 and released in 1991, with
the aim to correct the defects present in other languages and to take their
strengths. The name Python derives from the passion of Guido for the group
of British comedians Monty Python
• Since then Python has grown and has found increasing popularity, first in
Web development and, especially in recent years, in the field of data science
• It is an open source language, constantly improved by the developer
community, and completed by several libraries
Info: https://www.python.org/about/
18
• Python can be used for creating prototypes of applications, that later will be
fully developed with more complex or specific languages
20
Installing Python
Check the version of the operating system/system type to choose the right download
Win
64
Win
32
IMPORTANT!
23
Shell
Editor
24
Opening IDLE
Opening IDLE from the operating system menu will open the shell window
For our first simple examples we will work in the shell, afterwards we will
move to the editor, that is where we really write programs
25
IDLE customization
In the shell:
You can use other tools, in addition to IDLE, to develop in Python. The most
popular are:
• Anaconda: www.anaconda.com
• Pythonanywhere: www.pythonanywhere.com
• Atom : https://atom.io/
27
Book references
Learning Python:
Chapters 1, 2.1, 2.2, 2.3