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
- Getting Started: Language Download
- Getting Started: Development Tools
- Getting Started: Testing
- Getting Started: Deployment
- Beginner Tutorials
- Intermediate Tutorials
- Advanced Tutorials
- Good Beginner Blog
- Good Intermediate Blog
- Good Advanced Blog
- Official Documentation
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