Syntax
Strings/Stdout
Conditionals/Control
Lists/Dictionaries
Monty Python
100
Which one of these is a valid single line comment?


// the grass is green

# the moon is full

/* the sun is bright

100
What will this code do?


dog = "rover"

print dog[2]

Prints "v" on the screen

100
What is wrong with this code?


color = "blue"

if color = "blue":
    print "the color is blue"

= should be ==

100
What is this data type and what is special about it?


(1, 2, 3)

tuple

The elements can't be changed, it is immutable

100
What weapon was used in Whither, Canada?

World's funniest joke

200
What is wrong with this code?


function pi():
    return 3.14

function should be def

200
How do you print the length of a string?

len(string)

200
What will this code do?


for color in ["red", "blue", "green"]
    print color

Produce a syntax error

the : is missing from the end of the for statement

200
What will this code do?


print ["red", "green", "blue"][1]

Print "green" on the screen

200
The Norwegian Parrot was only stunned.

True or False?

Explain why

False

The parrot was dead

300
What will this code do?


def howdy(parm1, parm2):
    print "howdy %s %s!" % (parm2, parm1)

print howdy("Alex", "Trebek")

Prints "Howdy Trebek Alex!" on the screen

300
How do you change the case of a string to all lower case?

string.lower()

300
What will this code do?


count = 0
while count < 10:
    print count
    count += 1

Print to the screen count from 0 to 9

300
What will this code do?


stuff = {"food": "pizza", "drink": "tea", 1:8}

print stuff[1]

Print "8" on the screen

300
Why did Watkins join the army?

For the water skiing

400
What is wrong with this code?


for i in [1,2,3,4,5]:
  if i == 3
    print i

missing : at end of the if statment

400
What is wrong with this code?


print "My dog's name is %s" %s "rover"

The second "%s" should be just "%"

400
What will this code do?


if 30 - (20 * 2) > 15:
    print "True"
else:
    print "False"

Print "False" on the screen

400
What is the code to add "yellow" to this list?


colors = ["red", "blue", "green"]

colors.append("yellow")

400
What injury did the Black Knight repeatedly suffer?

Flesh wound

500
What is a "sha-bang" and what does it do?

# followed by !

#!

Tells the shell where the appropriate interpreter is

500
Which of these will print the date and time in human readable format?


from datetime import datetime
print datetime.now()

import datetime
print datetime.datetime.now()

Both

500
What is wrong with this code?


if count == 7:
    print "count is 7"
else:
    print "count is unknown"
elif count == 8:
    print "count is 8"

else block should be last

500
What is the code to add the key/value pair "name": "puddintain" to dictionary "me"?

me["name"] = "puddintain"

500
What is Sir Lancelot's favorite color?

Blue