Lesson 1: Hello world
1
Why Python?
"Python" is an exciting programing because
• once you understand python, it's going to open up a
bunch of doors for you.
• there's over 300 000 packages that you can leverage in
python.
• the third most commonly-used language1, but placing
first for those who are not professional developers or
learning to code
1 Stackoverflow 2023 Developer Survey. https://survey.stackoverflow.co/2023
2
History of Python language
• It was created by Guido Van Rossum (1991) in his free
time when he worked on the Amoeba operating system
team (distributed OS developed by A. Tanenbaum).
• Python was created to solve the problems Amoeba had
when making system calls when connecting to Bourne
Shell (interpreter1 of default Unix version 7 systems).
• Python is inspired by languages ABC, Modula 3 and C.
• It's an interpreted language.
1 Computer program that translates and executes the commands that users introduce.
3
Python installation
Anaconda is one of the best Python distributions. It is oriented to give
comprehensive support to scientific development with Python. Among its
characteristics are:
• Graphic application that integrates the tools and versions of Python.
• IDE to easily develop scientific applications.
• Integrated package manager (Conda).
• Advanced integration with Jupyter Notebook.
• Support of Python virtual environments.
https://www.anaconda.com/download
4
Spyder
Spyder is an open source, cross-platform integrated development
environment (IDE) for scientific programming in the Python language.
5
Hello world
Generally when you introduce a program language, you do "hello world".
Python print() function prints the message to the screen or any other
standard output device.
Syntax : print(values to print)
6
Compiler
algorithm ComputeAge /* Program to compute a person’s age */
var #include <stdio.h>
BirthYear: integer
endvar void main()
{
Read (BirthYear) int birthYear, age;
Mov R2 1966
Age ß 2025 – BirthYear scanf (“%d”, &birthYear);
Mov R3 2025
if (Age >= 18) age = 2025 - birthYear;
write(“Legal age”)
if (age>= 18)
Sub R3 R2
Else
write(“Minor”) printf(“Legal age \n”);
endif else
printf(“Minor \n”);
endAlgorithm }
Algorithms High level Object
language
Compiler Linkage Executable
files
Libraries
7
Interpreter
algorithm ComputeAge """
Program to compute a person’s age
var
BirthYear: integer """
endvar
birthYear = int(input(“Write your Birth year:"))
Read (BirthYear)
age = 2025 - birthYear
Age ß 2025 – BirthYear
if (age >= 18):
if (Age >= 18) print("Legal age \n")
write(“Legal age”) else:
Else print(“Minor \n");
write(“Minor”)
endif Program run command by command
endAlgorithm
Algorithms High level
language
Interpreter
8
Compiled vs Interpreted
Compiled Interpreted
Ready to be They are not They are They require an
executed multiplatform multiplatform interpreter
Usually faster Low flexibility Easier to test Usually slower
Source code not Errors are easily
Linkage is needed Source code is public
available detected
9
Python properties
• Python supports several programming paradigms3:
– Object-oriented: Provides a programming model based on
objects that contain associated data and procedures known as
methods.
– Imperative: instructions are executed sequentially, one after
another, unless conditional control structures are found.
– Functional: treats computing as a process of application of
functions, avoiding moving data with their changes of state.
• It is a high-level language. It manages its resources
(especially memory). It is easy to read and flexible.
• It is a strongly typified language4 and dynamic typed5.
3 A paradigm is a way of representing and manipulating knowledge.
4 Any attempt to perform an operation on the wrong type triggers an error. 10
5 It determines the type of operations at runtime.
Advantages of Python
• It is a very portable language, that is, it is independent of
the architecture of the machine. Python programs run on a
virtual machine.
• Its grammar is elegant. It allows writing clear, concise and
simple code, and develop a lot of use cases in an elegant
and natural way.
• Large set of functions in the standard library and lots of
external projects with specific functionalities.
• Its interface with C, C++ and Java facilitates the
connection between heterogeneous programs.
11
Disadvantages of Python
• Since it is an interpreted language, it is considered a slow
language, although Python 3 improves its performance.
• It is less extended than other languages such as C/C++
or Java, although it is increasing.
• It is not a very good language for mobile development.
• It's not a good choice for memory-intensive tasks.
• It has limitations regarding the access to databases.
12