Python QuickStart


# This is a one-line Python comment - code blocks are so useful!
"""This type of comment is used to document the purpose of functions and classes."""


# Remember values, not variables, have data types.
# A variable can be reassigned to contain a different data type.
answer = 42
answer = "The answer is 42."

Data Types

boolean = True
number = 1.1
string = "Strings can be declared with single or double quotes."
list = ["Lists can have", 1, 2, 3, 4, "or more types together!"]
tuple = ("Tuples", "can have", "more than", 2, "elements!")
dictionary = {'one': 1, 'two': 2, 'three': 3}
variable_with_zero_data = None

Simple Logging

print "Printed!"


if cake == "delicious":
    return "Yes please!"
elif cake == "okay":
    return "I'll have a small piece."
    return "No, thank you."


for item in list:
    print item
while (total < max_val):
    total += values[i]
    i += 2


def divide(dividend, divisor):
    quotient = dividend / divisor
    remainder = dividend % divisor
    return quotient, remainder

def calculate_stuff(x, y):
    (q, r) = divide(x,y)
    print q, r


class Person(object):
    def __init__(self, name, age): = name
        self.age = age 

    def birthday(self):
        self.age += 1