Lecture 01 02
Lecture 01 02
PYTHON
Preliminaries Algorithm
Assignment 3
Simple is better 3
than complex.
Perl:
•There is more than one way to do it
Python:
•There should be one – and preferably
one – obvious way to do it
You can run it by executing the following command (the hello_world.py file must be
in your current working terminal directory):
$ python hello_world.py
Hello world
Be aware of current
Keyboard Language mode:
ENG – VIE change it to
ENG
Facebook.com/MagicCodeInstitue/ Le Van Tiep & 0982 521 378 18
2 IPYTHON BASICS
Running the Jupyter Notebook
One of the major components of the Jupyter project is the notebook, a type of interactive document for
PYTHON OVERVIEW
code, text (with or without markup), data visualizations, and other output. The Jupyter notebook
interacts with kernels, which are implementations of the Jupyter interactive computing protocol in any
number of programming lan guages. Python’s Jupyter kernel uses the IPython system for its
underlying behavior.
terminal Python interpreter (invoked with python). One of the major improvements over the
standard Python shell is tab completion, found in many IDEs or other interactive computing
analysis environments. While entering expressions in the shell, pressing the Tab key will search
the namespace for any variables (objects, functions, etc.) matching the characters you have typed
so far:
Magic
Commands
• Control Flow
model. Every number, string, data structure, function, class, module, and so on exists
in the Python interpreter in its own “box,” which is referred to as a Python object.
Each object has an associated type (e.g., string or function) and internal data. In prac‐
tice this makes the language very flexible, as even functions can be treated like any
other object.
Comments
Any text preceded by the hash mark (pound sign) # is
ignored by the Python interpreter. This is often used to
add comments to code. At times you may also want to
exclude certain blocks of code without deleting them. An
easy solution is to comment
out the code
• Tuple
• Dictionary
• Built-in functions
PYTHON OVERVIEW
• User-defined functions
• *
• **
• ***
• ****
• *****