2. 2
Why Python?
Free
Easy to learn
Easy communication
Efficient code
Universal
Rich collection of numerical
methods, plotting or data
processing tools.
3. 3
Python Language
Python, a generic and modern computing language:
• The language: flow control, data types (string, int), data collections (lists,
dictionaries), etc.
• Modules of the standard library: string processing, file management,
simple network protocols.
• A large number of specialized modules or applications written in Python:
web framework, etc. … and scientific computing.
• Development tools (automatic testing, documentation generation)
Unlike Matlab, or R, Python does not come with a pre-bundled set
of modules for scientific computing.
5. 5
Installing Python
There is two ways to Start working with python:
1- download and install the python language interpreter from the official
web site :
https://www.python.org/
Then start to install the required libraries one by one.
2- install a scientific-computing distribution, that comes readily with
optimized versions of scientific modules. For Example:
- Anaconda (recommended) - EPD - WinPython
Download Anaconda from : https://www.anaconda.com/download/ choose your
Operating system and python 3.7
7. 7
interactive environments and
text editors
There is many methods to start programming using python includes:
1- Using Command window
3- Using Interactive environments
2- Using Text Editors and IDEs
Using Command window:
• Open anaconda prompt
• Type Python ⏎
(The python command windows is start working)
8. 8
interactive environments and
text editors (cont.)
Using Interactive environments (my recommend method during learning)
an interactive work with the IPython console from anaconda prompt, or its
offspring, the Jupyter notebook from Anaconda Navigator.
Start Anaconda Navigator
Launch Jupyter notebook and start working
See also
• IPython user manual: http://ipython.org/ipython-doc/dev/index.html
• Jupyter Notebook QuickStart: http://jupyter.readthedocs.io/en/latest/content-quickstart.html
9. 9
interactive environments and
text editors (cont.)
Using Text editors and IDEs
Tens IDEs are available for python but the best of them includes:
• Microsoft Visual Studio
• Pycharm IDE
• Pydev IDE
• Vim
• Atom
• Netbeans
See also
https://www.visualstudio.com/vs/python/
10. 10
Python Language
Python is a programming language, as are C, Fortran, BASIC, PHP, etc.
Some specific features of Python are as follows:
• an interpreted (as opposed to compiled) language. Python can be
used interactively.
• a free software released under an open-source license: Python can be
used and distributed free of charge, even for building commercial
software.
• multi-platform: Python is available for all major operating systems.
• a very readable language with clear non-verbose syntax
• a language for which a large variety of high-quality packages are
available for various applications, from web frameworks to scientific
computing.
• a language very easy to interface with other languages, in particular C
and C++.
• Some other features of the language are illustrated just below. For
example, Python is an object-oriented language, with dynamic typing
(the same variable can contain objects of different types during the
course of a program).
11. 11
Python Basics
• Command Line Window
The >>> is called a prompt. This is where python waits for instructions.
It is like an ear constantly waiting for orders to be executed. Entering an
instruction means typing it at the command line prompt and
pressing return.
>>>
>> x = 9 # assign the value 9 to x
12. 12
Python Variables
A variable is a name that refers to a value.
In Python, No need to declare variables
An assignment statement creates new variables and gives them values.
13. 13
Python Variables (cont.)
Programmers generally choose names for their variables that are
meaningful and document what the variable is used for.
Variable names can be arbitrarily long.
They can contain both letters and numbers, but they cannot start with a
number.
They can contain underscore character (_).
If you give a variable an illegal name, you get a syntax error.
Python's keywords cannot be used as variable names.
Python reserves 33 keywords:
16. 16
Asking the user for input
Python provides a built-in function called input that gets input from the
keyboard.
When this function is called, the program stops and waits for the user to
type something.
When the user presses Return or Enter, the program resumes and input
returns what the user typed as a string.
17. 17
Comments
Comments in Python start with the hash character, #, and extend to the
end of the physical line.
A comment may appear at the start of a line or following whitespace or
code, but not within a string literal.
A hash character within a string literal is just a hash character.
Comments are to clarify code and are not interpreted by Python, they may
be omitted when typing in examples.
18. 18
Resources
Scipy Lecture Notes
http://www.scipy-lectures.org/
Python for Everybody
https://www.py4e.com/
Python official documentation
https://docs.python.org
Anaconda web site
https://www.anaconda.com