Python Tutorial
Python - Introduction Python - Syntax Python - Variable Python - Number Python - Casting Python - String Python - Operators Python - Conditions Python - Loops Python - List Python - Tuple Python - Set Python - Dictionary Python - Function Python - Module Python - Date & Time Python - Input Output Python - Error & Exception Python - File Handling
Python OOP
OOP - Introduction OOP - Class Members OOP - Constructor Destructor OOP - Data Hiding OOP - Inheritance OOP - Overriding OOP - Overloading

Python Introduction

What is Python?

Python is a popular programming language. It was created in 1991 by Guido van Rossum.

It is used for:

  • web development (server-side)
  • software development
  • mathematics
  • system scripting

What can Python do?

  • Python can be used on a server to create web applications.
  • Python can be used alongside software to create workflows.
  • Python can connect to database systems. It can also read and modify files.
  • Python can be used to handle big data and perform complex mathematics.
  • Python can be used for rapid prototyping, or for production-ready software development.

Why Python?

  • Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
  • Python has a simple syntax similar to 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-orientated way or a functional way.

Features of Python

  • Easy-to-learn - Python has few keywords, simple structure, and a clearly defined syntax.
  • Easy-to-maintain - Python's source code is fairly easy-to-maintain.
  • A broad standard library - Python's bulk of the library is very portable and cross-platform compatible on UNIX, Windows, and Mac.
  • 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.

Python Install

Many PCs will have python already installed.

To check if you have python installed, open the Terminal and type:

If you find that you do not have python installed on your computer, then you can download it for free from the following website:

Python Quickstart

Python is an interpreted programming language, this means that as a developer you write Python (.py) files in a text editor and then put those files into the python interpreter to be executed.

The way to run a python file is like this on the command line:


The Python Command Line

To test a short amount of code in python sometimes it is quickest and easiest not to write the code in a file. This is made possible because Python can be run as a command line itself. Type python in your terminal:

From there you can write any python code:

Which will write "Hello, World!" in the command line:

Whenever you are done in the python command line, you can simply type the following to quit the python command line interface: