A Comprehensive Overview of Python Programming

undefined
 
G
a
l
 
R
a
t
t
n
e
r
 
Introduction to Python programming
 
What is python?
Installation
Conda
Virtual environments & Interpreters
Packages
Syntax
Functions
Examples
Links
 
 
 
 
O
u
t
l
i
n
e
s
 
Python is a dynamic (compiled at runtime) programming language, gaining
huge popularity in the recent years
Created in 1991 by Guido van Rossum
It is open source 
 packages are developed and released by programmers
frequently
There are two main versions to python:
Python 2.x (late is 2.7) 
 will be deprecated by 2020
Python 3.x (3.5/3.6/3.7) - mainly used
Easy to learn 
 mainly used for server programming, mathematics (replacing
matlab), ML etc.
 
 
W
h
a
t
 
i
s
 
p
y
t
h
o
n
?
 
Installation can be done in few ways:
Python.org
Anaconda3
 
 managing installation of packages
Pycharm 
 JetBains Integrated Development Environment (IDE) for python
 
We will install Conda and open Virtual environment
Then we will install pycharm and define the environment as the project
interpreter
 
 
 
I
n
s
t
a
l
l
a
t
i
o
n
 
Installing Anaconda3
https://conda.io/docs/user-guide/install/windows.html#install-win-silent
Pay attention that you install with the proper 3.x python version
Using CMD prompt:
 
 
 
 
 
 
The environments can be switched using 
‘activate <name>’ 
, 
‘deactivate <name>’
The 
*  
signify which 
env
 is now active
 
I
n
s
t
a
l
l
a
t
i
o
n
 
Installing Pycharm
Pycharm is one of the common IDEs (like MS Visual Studio for example)
It is very comfortable and adjusted for remote connection and ML development
 
Installation link:
https://www.jetbrains.com/help/pycharm/install-and-set-up-pycharm.html
 
Make sure to install the full version and not ‘community edition ’ (CE) for
remote control ability.
 
I
n
s
t
a
l
l
a
t
i
o
n
 
Open a new project and select the ‘interpreter’ to be
the 
conda virtual env
 you created.
 
 
 
 
 
 
 
 
 
or in: 
 
File 
 settings 
 project interpreter
 
 
I
n
s
t
a
l
l
a
t
i
o
n
 
The basic Python language is very thin and shallow
Extensions are added manually to each project as 
‘import <package>’
 command
Import should be used at the top of each python script file
Some of the common packages
numpy
 
 dealing with numbers and mathematics
pickle
 
 save/load files
os
  - operations on files (move/remove/create)
time
  - times calculation
tensorflow/torch
 
 ML packages
 
 
 
 
*You can import a class/subpackage from a package, or rename an imported package
 
P
y
t
h
o
n
 
p
a
c
k
a
g
e
s
 
One of the most important packages for research work is numpy
numpy has many Matlab-like functions and operators
np.ones(100,10)
np.squeeze()
np.linspace()
Etc.
Use shortcut:
import
 
numpy 
as
 np
 
All mathematics and vector operations should be done ONLY using np, for
efficiency and preciseness
Python math operations often include substantial errors
 
 
 
P
y
t
h
o
n
 
p
a
c
k
a
g
e
s
 
Python data structures
list
 
 the basic array structure in python, bound with [], can contain more than one data types
[1, 2, 4, ‘stam_string’, 8, 16]
np.array
  -- the numpy array type, used for vector/matrix  math
dictionary
 
 complex data structure that stores 
“keys”
 and their 
‘values’
{”name” :  ‘gal’, ”age” : 29, “occupation” : ‘researcher’}
 
Syntax
Indentation !!!
Data copying 
 make sure to use 
‘copy’
 package to
 deep copy 
non scalar data objects
Make sure not to use 
saved words 
as variables names (
in, list, len
, etc.)
dot dot colon  ‘ 
: 
 
 
 
 
P
y
t
h
o
n
 
s
y
n
t
a
x
 
OOP 
 define classes and call them to create objects
init() functions
Properties (@propery)
private functions 
 for effective and easy coding
Use vectorization of the calculation (instead of for loops) 
 reduces runtime by 1-2
orders
Use global variables to use common data between functions
Use pycharm 
debug mode 
all the time!
 
 
 
 
P
y
t
h
o
n
 
t
i
p
s
 
 
E
x
a
m
p
l
e
s
undefined
 
Questions
 
Python tutorials:
https://www.w3schools.com/python/python_getstarted.asp
https://www.learnpython.org/
Conda:
https://conda.io/docs/user-guide/getting-started.html
Pycharm:
https://www.jetbrains.com/pycharm/documentation/
Linux tutorial (for server work):
https://www.tutorialspoint.com/unix/
Michael Nielsen ML book & examples:
http://neuralnetworksanddeeplearning.com/chap1.html
 
 
 
L
i
n
k
s
Slide Note
Embed
Share

Python is a dynamic programming language that has gained immense popularity since its creation in 1991. This article covers topics such as the basics of Python, installation methods including Conda and PyCharm, usage of virtual environments, interpreters, packages like NumPy for mathematics, and syntax and functions with examples. It also discusses the two main versions of Python - 2.x and 3.x, highlighting the impending deprecation of Python 2.x in 2020.

  • Python programming
  • Installation methods
  • Virtual environments
  • Packages
  • Syntax and functions

Uploaded on Oct 07, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Introduction to Python programming Gal Rattner

  2. Outlines What is python? Installation Conda Virtual environments & Interpreters Packages Syntax Functions Examples Links

  3. What is python? Python is a dynamic (compiled at runtime) programming language, gaining huge popularity in the recent years Created in 1991 by Guido van Rossum It is open source packages are developed and released by programmers frequently There are two main versions to python: Python 2.x (late is 2.7) will be deprecated by 2020 Python 3.x (3.5/3.6/3.7) - mainly used Easy to learn mainly used for server programming, mathematics (replacing matlab), ML etc.

  4. Installation Installation can be done in few ways: Python.org Anaconda3 managing installation of packages Pycharm JetBains Integrated Development Environment (IDE) for python We will install Conda and open Virtual environment Then we will install pycharm and define the environment as the project interpreter

  5. Installation Installing Anaconda3 https://conda.io/docs/user-guide/install/windows.html#install-win-silent Pay attention that you install with the proper 3.x python version Using CMD prompt: The environments can be switched using activate <name> , deactivate <name> The * signify which env is now active

  6. Installation Installing Pycharm Pycharm is one of the common IDEs (like MS Visual Studio for example) It is very comfortable and adjusted for remote connection and ML development Installation link: https://www.jetbrains.com/help/pycharm/install-and-set-up-pycharm.html Make sure to install the full version and not community edition (CE) for remote control ability.

  7. Installation Open a new project and select the interpreter to be the conda virtual env you created. File settings project interpreter or in:

  8. Python packages The basic Python language is very thin and shallow Extensions are added manually to each project as import <package> command Import should be used at the top of each python script file Some of the common packages numpy dealing with numbers and mathematics pickle save/load files os - operations on files (move/remove/create) time - times calculation tensorflow/torch ML packages *You can import a class/subpackage from a package, or rename an imported package

  9. Python packages One of the most important packages for research work is numpy numpy has many Matlab-like functions and operators np.ones(100,10) np.squeeze() np.linspace() Etc. Use shortcut: import numpy as np All mathematics and vector operations should be done ONLY using np, for efficiency and preciseness Python math operations often include substantial errors

  10. Python syntax Python data structures list the basic array structure in python, bound with [], can contain more than one data types [1, 2, 4, stam_string , 8, 16] np.array -- the numpy array type, used for vector/matrix math dictionary complex data structure that stores keys and their values { name : gal , age : 29, occupation : researcher } Syntax Indentation !!! Data copying make sure to use copy package to deep copy non scalar data objects Make sure not to use saved words as variables names (in, list, len, etc.) dot dot colon :

  11. Python tips OOP define classes and call them to create objects init() functions Properties (@propery) private functions for effective and easy coding Use vectorization of the calculation (instead of for loops) reduces runtime by 1-2 orders Use global variables to use common data between functions Use pycharm debug mode all the time!

  12. Examples

  13. Questions

  14. Links Python tutorials: https://www.w3schools.com/python/python_getstarted.asp https://www.learnpython.org/ Conda: https://conda.io/docs/user-guide/getting-started.html Pycharm: https://www.jetbrains.com/pycharm/documentation/ Linux tutorial (for server work): https://www.tutorialspoint.com/unix/ Michael Nielsen ML book & examples: http://neuralnetworksanddeeplearning.com/chap1.html

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#