number_list = [1, 2, 4, 8, 16, 32]
the_pythons = ["Graham", "Terry",  "Michael", "Eric", "Terry", "John"]
mixed = [1, "Terry", 4]

print (mixed)

"""
Explanation: Overview

Hour 1
Tuples
Dictionaries
Take Up Midterm
Hours 2 and 3
Work Time

Lists

A list is an object that contains multiple data items
Lists are mutable
Lists can be indexed and sliced
Lists have methods

Syntax

Square brackets
Commas as separators
End of explanation
"""


monty = ("Graham", "Terry",  "Michael", "Eric", "Terry", "John")

# the entire tuple
print (monty)

# one element at a time
for name in monty:
    print(name)

# indexing
print(the_pythons[2])

print(monty[2])


"""
Explanation: Tuple

A tuple is an immutable version of a list
Immutable means that the contents cannot change after creation

Syntax

Parentheses
Commas as separators
End of explanation
"""


# monty is the tuple, and the_pythons is a list
print (monty)
print (list(monty))

print (the_pythons)
print (tuple(the_pythons))

"""
Explanation: [] brackets or square brackets
() parentheses
{} curly braces or braces
Converting Between Lists and Tuples
list()
tuple()
End of explanation
"""


# Safer than constants, because it is enforced by interpreter
CONVERSION_CONSTANT = 5/9


"""
Explanation: Why?

Performance
Tuples are faster
Safety
Can't be modified

Looking ahead: tuples can be keys in a dictionary, but lists can't
End of explanation
"""


my_dict = {}
my_dict[3.14] = "pi"
my_dict["pi"] = 3.14159
my_dict[(1,2)] = "x,y coordinates"
my_dict[(2,3)] = "x,y coordinates"
print my_dict

my_dict[(1,2)] = [4, 5, 6, 7]
print my_dict

len(my_dict)

phone_book = {"Graham":"555-111", 
              "Terry": "555-2222", 
              "Michael": "555-3333"}

"""
Explanation: Dictionaries

A dictionary is a collection data structure. Each element in a dictionary has two parts: a key and a value. You use a key to locate a specific value.
Shorthand description: a dictionary is like a list, but instead of the index being a number, the index is any value, e.g. int, float, string, tuple, etc.
Think dictionaries and phone books
End of explanation
"""


phone_book

phone_book['Michael']

my_dict[(1,2)]

phone_book['Wanda']

"""
Explanation: Retrieving a Value from a Dictionary
dictionary[key]
End of explanation
"""


# Using 'in'

if "Michael" in phone_book:
    print phone_book["Michael"]

# Using 'not in'

if "Wanda" not in phone_book:
    print("Fish don't need phone numbers")

"""
Explanation: Testing for Value in a Dictionary
End of explanation
"""


print(phone_book)

# Eric, Terry, John

phone_book["Eric"] = "555-4444"
phone_book["Terry"] = "555-5555"
phone_book["John"] = "555-6666"

"""
Explanation: Adding Elements to a Dictionary
End of explanation
"""


del phone_book["John"]

print(phone_book)

"""
Explanation: Deleting Elements
del dictionary[key]
End of explanation
"""


if 'Michael' in phone_book:
    del phone_book['Michael']

print(phone_book)

if '555-4444' in phone_book:
    print ("Can match values too!")

"""
Explanation: Putting it together

Test for presence of key before deletion
End of explanation
"""


for name in phone_book:
    print (name, phone_book[name])

"""
Explanation: Iterating over a Dictionary
End of explanation
"""


phone_book.items()

phone_book.keys()

phone_book.values()

if '555-4444' in phone_book.values():
    print("We can match values too")

"""
Explanation: Dictionary Methods
End of explanation
"""


even = False
if even = True: 
    print("It is even!")


154 >= 300 != False

def is_equal(t1, t2):
#    return t1 == t2
    return t1.sort() == t2.sort()

list1 = ["name", "age", "temp"]
list2 = ["name", "temp", "age"]

if is_equal(list1, list2):
    print("Same!")
else:
    print ("Different!")

"""
Explanation: Midterm Discussion
End of explanation
"""


