1
CST 445
PYTHON FOR ENGINEERS
2
Getting Started with Python Programming
► Guido van Rossum invented the Python programming language in the early
1990s.
► Python is a high-level, general-purpose programming language for solving
problems on modern computer systems.
► The language and many supporting tools are free, and Python programs can run
on any operating system.
3
Instructions for downloading and installing
Python
► Downloads
► [Link]
4
Running Code in the Interactive Shell
► Python is an interpreter language.
► It means it executes the code line by line.
► Python provides a Python Shell (also
known as Python Interactive Shell) which
is used to execute a single Python
command and get the result.
► Python Shell waits for the input command
from the user.
► As soon as the user enters the command,
it executes it and displays the result.
5
Running Code in the Interactive Shell
6
Running Code in the Interactive Shell
► When you enter an expression or statement,
Python evaluates it and displays its result,
7
Execute Python Script
► To execute multiple statements, create a
Python file with extension .py, and write
Python scripts (multiple statements).
► For example, enter the following statement in
a text editor such as Notepad.
►
8
Python - IDLE
► IDLE (Integrated Development and Learning ► IDLE can be used to execute a single
Environment) is an integrated development statement just like Python Shell and also to
environment (IDE) for Python. create, modify and execute Python scripts.
► The Python installer for Windows contains the ► IDLE provides a fully-featured text editor to
IDLE module by default. create Python scripts that includes features
like syntax highlighting, autocompletion and
► IDLE is not available by default in Python
smart indent.
distributions for Linux.
► It also has a debugger with stepping and
► It needs to be installed using the respective
breakpoints features.
package managers.
►
9
Python - IDLE
► To start IDLE interactive shell, search for the
IDLE icon in the start menu and double click
on it.
►
10
Python - IDLE
► This will open IDLE, where you can write
Python code and execute it as shown below.
11
► Now, you can execute Python statements same
as in Python Shell as shown below.
12
► To execute a Python script, create a new file
by selecting File -> New File from the menu.
13
14
Color-coding
coding of Python program elements in
IDLE
Python Editors (IDE) 15
► There are many free and commercial editors
available for Python.
► Ipython( Interactive Python.)
► Jupyter Notebook
16
Jupyter Notebook
► The Jupyter Notebook is a browser-based graphical interface to the IPython shell.
► It allows the user to include formatted text, static and dynamic visualizations,
mathematical equations, JavaScript widgets etc
etc. along with the Python code.
► The Jupyter Notebook document can be exported to PDF, Python script or
HTML.
► By default, the IPython kernel drives the Jupyter Notebook application.
However, it supports other languages like Julia and R.
Jupyter stands for JUlia, PYThon and R