Introduction to Python
What is Python?
- Implemented by Guido van Rossum in 1989 , named after a BBC TV
show called ‘Monty Python’s Flying Circus’
- First Version released in 1991
- Python is an Object Oriented Programming Language
- Python is Interpreted, features an easy syntax and dynamic typing
- Python is designed to be easily extensible by writing pure python
modules or writing modules in C (eg NumPy)
- Latest Version Python 3.12.0
Python in a nutshell..
- Is general purpose scripting language
- Is a cross-platform compatible language
- Used to code a variety of applications
- Is a beginner-friendly language
Why Python?
- Easy to understand and write
- Free & Open Source
- High level language
- Portable
- Interpreted
- Object oriented
- Extensible
- Extensive Libraries
Brief Version Timeline
1991 - Guido publishes Python v0.90
1994 - Python v1.0 - (functional programming- lambda, map, filter, reduce)
2000 - Python 2 (list comprehension & garbage collection)
2008 - Python 3 (note Python3 is not backwards compatible )
2020 - Python2 end of life
Installation Guide : Windows
1. Using Official Python Installer
- Go to https://www.python.org/downloads/, download a python installer
and make sure to check the add python to path box
Installation Guide : Windows
2. Using Microsoft Store
- Open Microsoft Store & search for Python
- Select newest version (Python3.12.0) and install it
3. Verify your installation by typing: py -3 version
Installation Guide : Linux
1. Check if Python is installed :
python3 --version
2. Using a package manager:
sudo apt-get update && sudo apt-get install python3
3. Verify Installation:
python3 -V
Your First Program
Instructions:
1. Open your terminal
2. Open Python prompt by typing python3
3. Type print(“Hello World!) followed by [enter] key
Selecting an Editor
- VSCode - https://code.visualstudio.com/ and Install the Python
extension: https://code.visualstudio.com/docs/languages/python
- Pycharm (Get a Student license via Github Students:
https://education.github.com/pack) then apply for student licenses on
Jetbrains (https://www.jetbrains.com/)
- PyDev : https://www.pydev.org/download.html
- Standard Editors such as Vi & Nano
The Python Interpreter
1. Operates like the Unix shell, executes commands interactively with
standard input and reads and executes a script when called with a file
as input
2. Is invoked using python3 on terminal
Python File and Scripts
- Create a python file that has .py extension e.g filename.py
- Write the previous code:
print(“Hello World!”)
- Execute it by typing:
python3 filename.py
Exercise
1. Create a file named sum.py and save it to your Desktop Directory
2. Write a program in sum.py to calculate the sum of two numbers
3. Execute this file using your terminal
4. Output should be as follows: The sum of the numbers is : [your sum]
Happy Coding!!
*********
Next Lesson
Python Basics
- Data Types (Strings, Numbers, Variables, Objects)
- Code Formatting
- Operators and Expressions
- Flow Control ( If, if-else, if- elif, while, break & continue statements)
- Loops (For..in )
- Python Code Style Guide - PEP-8
- Exercise
Python Practice Resources
- https://www.python.org/shell/
- https://repl.it/languages/python3
- https://www.tutorialspoint.com/execute_python3_online.php
- https://trinket.io/python3