Lecture 2 Python Self notes
Lecture 2 Python Self notes
Python3 programming
Lecture 2
What is Python?
• Python is a popular programming
language. It was created by Guido van
Rossum, and released in 1991.
• It is used for:
• Web development (server-side),
• Game Development
• Scientific and Numeric Applications
• Artificial Intelligence and Machine
Learning
• Desktop GUI
• Software Development
• Education programs and training courses
Why python?
• Python works on different platforms (Windows, Mac, Linux,
Raspberry Pi, etc).
• Python has a simple syntax like the English language.
• Python has syntax that allows developers to write programs with
fewer lines than some other programming languages.
• Python runs on an interpreter system, meaning that code can be
executed as soon as it is written. This means that prototyping can
be very quick.
• Python can be treated in a procedural way, an object-oriented
way or a functional way.
Python Features
• Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This allows a student to pick
up the language quickly.
• Easy-to-read − Python code is more clearly defined and visible to the eyes.
• Easy-to-maintain − Python's source code is fairly easy-to-maintain.
• Interactive Mode − Python has support for an interactive mode which allows interactive testing and debugging of
snippets of code.
• Portable − Python can run on a wide variety of hardware platforms and has the same interface on all platforms.
• Extendable − You can add low-level modules to the Python interpreter. These modules enable programmers to add to
or customize their tools to be more efficient.
• Databases − Python provides interfaces to all major commercial databases.
• GUI Programming − Python supports GUI applications that can be created and ported to many system calls, libraries
and windows systems, such as Windows MFC, Macintosh, and the X Window system of Unix.
• Scalable − Python provides a better structure and support for large programs than shell scripting.
Python Execution Model
There are several ways in which you can run a
Python program, including:
A script is a stand-alone file that can be run directly without the need to (explicitly) use the
python command.
This is done by adding a special line to the start of the Python file that indicates the Python
command (or interpreter) to use with the rest of the file.
This line must start with '#!' and must come at the start of the file.
To convert the previous section’s file into a Script we would need to add the path to the python
interpreter.
Here path refers to the route that the computer must take to find the specified Python
interpreter (or executable).
Executing a Python Script
Installing Python on a Windows PC
Setting up the path of python