Python Overview

Photo by Marius Masalar on Unsplash
Photo by Marius Masalar on Unsplash

Introduction to Python

Python is a high-level, general-purpose, compiled programming language. Python features a dynamic type system and automatic memory management. It supports multiple programming paradigms, including object-oriented, imperative, functional and procedural, and has a large and comprehensive standard library.

History

Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, and a syntax that allows programmers to express concepts in fewer lines of code, notably using significant whitespace. By the way, the language is named after the BBC show “Monty Python’s Flying Circus” and has nothing to do with reptiles.

Python Resources

Quick Reference – Python

Here is a quick reference for the basics of Python…

Hello World in Python

yourName = input("What is your name?")
print("Hello " + yourName + "!")

Python: Basic Syntax

Variables & Data Types

Python uses dynamic variable typing, so the variable type will change to match the data assigned to it.

Branching

if condition:
    # do something
elif: 
    # do something else
else:
    # do something else 

Lists

primeNumbers = [2, 3, 5, 7, 13]
primeNumbers.append(17)
len(primeNumbers)

Loops

You can loop through all the items in an array:

string[] myList = {"one", "two", "three", "four", "five"};

for item myList:
    print(item)

You can loop a fixed number of times:

for i in range(5):
    print(i);

You can loop while a condition is true:

while condition==true:
    # do something that may change the condition

Books on Python