What would be the output of the following?
>>> name = 'Mark'
>>> print 'Hello, ' + name
Hello, Mark
(True or false) A picture is represented in the computer as a matrix of color values for each pixel in the picture.
True
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 numerical representation of the following binary value?
00000100
4
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?
The context of the variable 'a' is only valid inside the function.
The output of:
>>> 'CPS121' * 3
'CPS121CPS121CPS121'
A
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
Say (or write on the board) the binary representation of the number 16.
00010000
>>>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 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.
What would the following command give you?
>>>name='Gordon'
>>>len(name)
6
Suppose a certain pixel in a picture had the color values:
Red = 100 Green = 50 Blue = 150
If we converted this picture to grayscale, what would be the Red, Green, and Blue values for this new pixel?
Red = 100 Green = 100 Blue = 100
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 name[1:6:2]
odn
This would process characters 1 through 5 (not including 6), with an increment value of 2.
What would be the outcome of the following?
This function will decreases size of the src image by 50% and crop the image.