python intermediate - alessio vaccaro
TRANSCRIPT
![Page 2: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/2.jpg)
![Page 3: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/3.jpg)
![Page 4: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/4.jpg)
set
![Page 5: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/5.jpg)
list tuple set
set()
![Page 6: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/6.jpg)
Sets
methods.intersection().union().difference()
![Page 7: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/7.jpg)
set sets
methods .add() .update() .remove() .discard()
![Page 8: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/8.jpg)
list comprehension lists
![Page 9: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/9.jpg)
generators generator list next()
![Page 10: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/10.jpg)
list list
![Page 11: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/11.jpg)
list list
![Page 12: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/12.jpg)
![Page 13: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/13.jpg)
![Page 14: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/14.jpg)
1
-
![Page 15: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/15.jpg)
1
-
![Page 16: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/16.jpg)
![Page 17: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/17.jpg)
class
class attributes Classmethods class
1. Created a class in a saved script;2. Launched the script in the shell;
![Page 18: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/18.jpg)
class
class attributes Classmethods class
I can access attributes of my class by using the proper syntax.
![Page 19: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/19.jpg)
attributes
![Page 20: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/20.jpg)
function class
![Page 21: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/21.jpg)
![Page 22: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/22.jpg)
class self.year None
![Page 23: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/23.jpg)
__str__ special function
![Page 24: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/24.jpg)
__str__ special function
![Page 25: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/25.jpg)
special function __dict__
![Page 26: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/26.jpg)
special functions
object.__str__(self)
object.__dict__(self)
object.__del__(self)
object.__hash__(self)
object.__repr__(self)
object.__bytes__(self)
object.__format__(self)
special functions
![Page 27: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/27.jpg)
![Page 28: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/28.jpg)
exceptions
![Page 29: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/29.jpg)
![Page 30: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/30.jpg)
handle exception try-except
![Page 31: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/31.jpg)
handle exceptions
![Page 32: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/32.jpg)
![Page 33: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/33.jpg)
Lambdas functions anonymous functions Lambdasfunction
lambda
function
![Page 34: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/34.jpg)
Lambdas attributes functions
![Page 35: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/35.jpg)
![Page 36: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/36.jpg)
Map function list
![Page 37: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/37.jpg)
lists list
![Page 38: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/38.jpg)
lists list list
sum len
![Page 39: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/39.jpg)
lists list list
sum len
list comprehension
![Page 40: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/40.jpg)
for map
sum len
![Page 41: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/41.jpg)
for list comprehension map
• for while
•
•
•
•
•
•
•
•
•
As little as possible
![Page 42: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/42.jpg)
Filter function
filter function numbers_list
lambda function module operator x%2
![Page 43: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/43.jpg)
filter list strings
![Page 44: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/44.jpg)
![Page 45: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/45.jpg)
Python
Python AnacondaPython
libraries
piptcl/tk
other
![Page 46: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/46.jpg)
libraries
piptcl/tk
other
> pip --version> pip 18.1
> pip install matplotlib> # to install something
> py -2 –m pip install matplotlib> # …selecting the right version of Py
> pip install --upgrade matplotlib> # to install and upgrade something
![Page 47: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/47.jpg)
libraries
piptcl/tk
other
piptcl/tk
![Page 48: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/48.jpg)
piptcl/tk
![Page 49: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/49.jpg)
Python
Python
![Page 50: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/50.jpg)
$ virtualenv –p /usr/bin/python3.6 «my_project»
$ source ‘path/to/env/bin/activate’
(my_project) user@localhost:~$
… do things in the environment…
(my_project) user@localhost:~$ deactivate
$
> virtualenv –p /usr/bin/python3.6 «my_project»
> ‘path/to/env/Script/activate’
(my_project) C://path/to/env >
… do things in the environment…
(my_project) C://path/to/env > deactivate
>
py -3 -m venv «my_project»
![Page 51: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/51.jpg)
![Page 52: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/52.jpg)
![Page 53: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/53.jpg)
…
…
![Page 54: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/54.jpg)
Repository
Working copy
![Page 55: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/55.jpg)
![Page 56: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/56.jpg)
Git
![Page 57: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/57.jpg)
![Page 58: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/58.jpg)
$ git config --global user.name "[my username]"
$ git config --global user.email "[my email address]"
![Page 59: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/59.jpg)
$ git init# I initialized my folder as a local repository
$ git clone git://github.com/link_to_project.git# I copy inside my local repository a perfect copy of the remote repository
… hours of work on the code …
$ git add .# my code is now in the staging area ready to be confirmed and committed into my local repository
$ git commit -m ‘Added support to X functionality‘# I committed my code to the local repository
$ git push origin master# I uploaded the content of my local repository to the remote repository
![Page 60: Python Intermediate - Alessio Vaccaro](https://reader030.vdocuments.us/reader030/viewer/2022040808/624d76992699a9303320aeeb/html5/thumbnails/60.jpg)
git init
git clone [url]
git add [file]
git add .
git commit –m "[message]"
git push [alias] [branch]
git pull