Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Corsi
Linux week
Introduzione a Python
Commits
b3d5c158
Commit
b3d5c158
authored
Nov 15, 2021
by
Guido Bordonaro
Browse files
Merge branch 'master' of
https://gitlab.poul.org/corsi/linux-week/python
parents
d9da064f
e7f401d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
b3d5c158
#
Python Courses
#
Linux week
## Python
101
## Python
Introduction
[

](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.poul.org%2Fcorsi%2F
Python%2Fintro.git/jupyter?file
path=index.ipynb)
[

](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.poul.org%2Fcorsi%2F
linux-week%2Fpython/HEAD?lab
path=index.ipynb)
[

](https://starboard.gg/jupystar?url=https%3A%2F%2Fgitlab.poul.org%2F
gubo97000
%2Fin
tro
%2F-%2Fraw%2F
jupy
ter%2Findex.ipynb)
[

](https://starboard.gg/jupystar?url=https%3A%2F%2Fgitlab.poul.org%2F
corsi
%2F
l
in
ux-week%2Fpython
%2F-%2Fraw%2F
mas
ter%2Findex.ipynb)
### Notebooks for edition
-
[

](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.poul.org%2Fcorsi%2FPython%2Fintro/2021?filepath=index.ipynb)
-
[

](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.poul.org%2Fcorsi%2FPython%2Fintro/2021-it?filepath=index.ipynb)
-
[

](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.poul.org%2Fcorsi%2FPython%2Fintro/2020?filepath=index.ipynb)
-
[

](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.poul.org%2Fcorsi%2Flinux-week%2Fpython/2021?labpath=index.ipynb)
index.ipynb
View file @
b3d5c158
%% Cell type:markdown id:exposed-parade tags:
<h1
class=
"intro_title"
style=
"text-align:center; font-size: 45px;"
>
Python course
2021
</h1>
<h2
class=
"intro_subtitle"
style=
"text-align:center; font-size: 30px;"
>
Python
101
</h2>
<h1
class=
"intro_title"
style=
"text-align:center; font-size: 45px;"
>
Linux Week
2021
</h1>
<h2
class=
"intro_subtitle"
style=
"text-align:center; font-size: 30px;"
>
Python
Introduction
</h2>
<img
class=
"intro_logo"
style=
"margin:auto; width:400px"
src=
"https://static.poul.org/assets/logo/logo_text_g.svg"
alt=
"POuL logo"
/>
<p
class=
"intro_author"
style=
"text-align: center; font-size: 18px;"
>
Guido Bordonaro
<
gubo97000@poul.org
>
<br/>
Guido Bordonaro
<
gubo97000@poul.org
>
<br/>
Giovanni Bezzetto
<
benzosnmilk@poul.org
>
<br/>
Andrei Tudor
<
x7upLime@poul.org
>
<br/>
</p>
%% Cell type:markdown id:00e3afed tags:
# Python
-
Ages very well 🐍 Latest version: 3.10.0
...
...
@@ -91,11 +90,10 @@
@
greet
(
"hello"
)
def
hello_world
():
print
(
"world"
)
hello_world
()
```
%% Cell type:markdown id:42e8c06b tags:
### The modular one
...
...
@@ -112,11 +110,10 @@
print
(
f
"hello,
{
self
.
who
}
"
)
clss
=
Class_hello
(
"world"
)
clss
.
hello
()
```
%% Cell type:markdown id:49c2a540 tags:
### The simple one
...
...
@@ -163,11 +160,10 @@
```
python
x
=
12
print
(
x
)
x
=
"a string"
print
(
x
)
```
%% Cell type:markdown id:169b5d47 tags:
### Duck typing
...
...
@@ -217,12 +213,10 @@
## Order of operations
x
=
10
y
=
5
print
((
x
%
y
)
+
1
**
2
/
2
)
## What is the result?
```
%% Cell type:markdown id:48686371 tags:
### A program using the things we just demonstrated
...
...
@@ -233,14 +227,14 @@
```
python
basket
=
14
print
(
f
"🍎 The basket contains
{
basket
}
apples."
)
added_apples
=
6
basket
+=
added_apples
# basket = basket + added_apples
print
(
f
"🍎
{
added_apples
}
apples were added,
for a total of
{
basket
}
apples."
)
print
(
f
"🍎 Sharing them with 3 people would leave
{
basket
%
3
}
apple in the basket"
)
print
(
f
"🍎
{
added_apples
}
apples were added,
"
f
"for a total of
{
basket
}
apples."
)
print
(
f
"🍎 Sharing them with 3 people would leave
"
f
"
{
basket
%
3
}
apple in the basket"
)
```
%% Cell type:markdown id:c57c59ee tags:
# [Control-Flow](https://docs.python.org/3/tutorial/controlflow.html)
...
...
@@ -271,11 +265,10 @@
print
(
0
==
False
)
print
(
1.1
>
1
)
print
(
2
<=
2
)
print
(
True
and
not
False
)
print
(
True
or
False
)
```
%% Cell type:markdown id:5a2ee7d0 tags:
## CONDITIONAL Execution
...
...
@@ -294,11 +287,10 @@
print
(
"[*] The basket contains 10 apples"
)
elif
basket
>
10
:
print
(
"[*] The basket contains more than 10 apples"
)
else
:
print
(
"[*] The basket contains less than 10 apples"
)
```
%% Cell type:code id:82f16964 tags:
```
python
...
...
@@ -306,11 +298,10 @@
if
basket
==
0
:
print
(
"[*] The basket is empty"
)
else
:
print
(
"[*] The basket contains something"
)
```
%% Cell type:markdown id:9efbb974 tags:
## Execution by ITERATION
...
...
@@ -333,38 +324,34 @@
basket
=
4
while
basket
>
0
:
#
basket
=
basket
-
1
print
(
f
"Gnam, we now have
{
basket
}
🍏"
)
print
(
"
\n
No more apples :("
)
```
%% Cell type:code id:b735e4f5 tags:
```
python
# Multiplication table
i
,
base
=
1
,
9
while
i
<=
10
:
print
(
f
"
{
base
}
*
{
i
}
=
{
i
*
base
}
"
)
i
+=
1
```
%% Cell type:code id:4bb34b90 tags:
```
python
for
value
in
[
"apples"
,
"bananas"
,
"pears"
,
"turkeys"
]:
print
(
value
)
```
%% Cell type:code id:07c05863 tags:
```
python
for
i
in
range
(
5
):
print
(
f
"
{
i
}
{
'🍎'
*
i
}
"
)
```
%% Cell type:markdown id:2ef8aa5d tags:
## break & continue
...
...
@@ -377,11 +364,10 @@
print
(
value
,
end
=
" "
)
if
value
==
"🤬"
:
print
(
"Error"
)
break
print
(
"Happy"
)
```
%% Cell type:code id:f1331407 tags:
```
python
...
...
@@ -389,11 +375,10 @@
print
(
value
,
end
=
" "
)
if
value
==
"🤬"
:
print
(
"Error"
)
continue
print
(
"Happy"
)
```
%% Cell type:markdown id:e6120a5b tags:
# Functions
...
...
@@ -420,29 +405,25 @@
```
python
def
say_hello
():
print
(
"Hello, world!"
)
say_hello
()
say_hello
()
```
%% Cell type:code id:b7602820 tags:
```
python
def
add_10
(
number
):
number
+=
10
print
(
number
)
add_10
(
2
)
add_10
(
1
)
# add_10()
# add_10("user")
```
%% Cell type:code id:3d5775fd tags:
```
python
...
...
@@ -468,11 +449,10 @@
add_10
(
2
)
add_10
(
1
)
add_10
()
# add_10("user")
```
%% Cell type:code id:bcd3c9c1 tags:
```
python
...
...
@@ -484,14 +464,12 @@
for
i
in
range
(
1
,
length
+
1
):
print
(
f
"
{
base
}
x
{
i
}
=
{
base
*
i
}
"
)
print
()
tables
(
2
,
4
)
tables
(
8
,
show_title
=
True
,
length
=
3
)
```
%% Cell type:markdown id:9e1c3bae tags:
## [Scope](https://docs.python.org/3/tutorial/classes.html#python-scopes-and-namespaces), or code visibility
...
...
@@ -526,12 +504,10 @@
fun3
()
fun1
()
fun2
()
print
(
f
"🌍: x =
{
x
}
"
)
```
%% Cell type:markdown id:f15f0b15 tags:
# Data Structures
...
...
@@ -688,16 +664,12 @@
<img
class=
"outro_logo"
style=
"width: 20%;"
src=
"https://static.poul.org/assets/logo/logo_g.svg"
alt=
"POuL logo"
>
<a
class=
"outro_license"
style=
"display: block; margin: 20px auto;"
rel=
"license"
href=
"http://creativecommons.org/licenses/by-nc-sa/4.0/"
><img
alt=
"Creative Commons License"
src=
"https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg"
/></a>
<p
class=
"outro_license_text"
style=
"font-size: 15px; text-align: center;"
>
Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
<br/>
Notebook source code available in
<a
href=
"https://gitlab.poul.org/corsi/
Python/intro
/-/tree/2021"
>
this repo
</a></p>
Notebook source code available in
<a
href=
"https://gitlab.poul.org/corsi/
linux-week/python
/-/tree/2021"
>
this repo
</a></p>
<p
class=
"outro_author"
style=
"text-align: center; font-size: 16px;"
>
Guido Bordonaro
<
gubo97000@poul.org
>
<br/>
Giovanni Bezzetto
<
benzosnmilk@poul.org
>
<br/>
Andrei Tudor
<
x7upLime@poul.org
>
<br/>
</p>
%% Cell type:markdown id:5c14cc92 tags:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment