What would be the output of the following?
>>> name = 'Mark'
>>> print 'Hello, ' + name
Hello, Mark
What is the out of the following?
>>>a[100, 30, 20]
>>>a
100, 30, 20
2+2
4
What is wrong with the following function?
def addOne(number): print number + 1
Everything is one line / there is no block indentation.
What would be the output of the following?
>>> a = 5
>>> b = 8
>>> a == b
False
The difference between these three:
"
'
"""
The first and second are interchangeable, the third includes paragraphs
What is the output of the following?
>>>a[100, 30, 20]
>>>a[2]
20
What is the outcome of the following?
>>> 7/3
2
Which is correct?
if (x==2):
print "yes"
if (x=2):
print "yes"
The first,
if (x==2):
print "yes"
What is wrong with the following?
def(setValue):
a = 5
__________________
>>> print a
The context of the variable 'a' is only valid inside the function.
The output of: >>> 'CPS121' * 3
'CPS121CPS121CPS121'
Describe the code needed to set a variable a that would store the values 100 and 20
>>> a[100, 20]
What is the outcome of the following?
>>> (50-5*6)/4
5
What would need to change to produce the desired outcome of 2.5?
>>>5 / 2
>>>5.0 / 2.0
or
>>>5.0 / 2
or 5 / 2.0
What would be printed after executing the following line of code?
>>> # print 5 + 5
Nothing!
What is the outcome of the following?
>>>word = 'GordonCollege'
>>>word[1:8]
ordonCo
What is the output of the following?
>>>a['green', 'eggs', 'ham']
>>>a[0] * 3
greengreengreen
>>>x = y = z = 6
>>> x * y
36
Describe what the following line would do:
for px in getPixels(pic):
This would begin a loop through each pixel in the image (pic).
What two numbers of the string correspond to "H" in variable i:
>>> i = "Hope"
-4 and 0:
a[-4]
a[0]
What would the following command give you?
>>>name='Gordon'
>>>len(name)
6
Double Jeopardy!!! Fill in the missing command:
>>> a = ['spam' , 'eggs' , 100 , 1234]
>>> ????????
>>> a
['spam', 'eggs', 123, 1234]
a[2] = a[2] + 23
What is the outcome of the following?
>>> '5' + 100
TypeError: cannot concatenate 'str' and 'int' objects
What output would you expect from the following?
>>> name = 'GordonCollege'
>>> print word[1:6:2]
odn
This would process characters 1 through 5 (not including 6), with an increment value of 2.
What will be accomplished by the following function?
def mystery(picture):
for p in getPixels(picture):
setBlue(p, getBlue(p) * 0.7)
setGreen(p, getGreen(p) * 0.7)
The picture will be processed to look like it was taken at sunset.