CSC 111 Quiz 3, Fall 2006

Submit by Tues October 17 by midnight


Name: First name :
Last name  :
Account name for copy (e.g., 111a-xx):
  
Quiz Code (password):

(Please take this quiz just once, unless you are told that the username or code is incorrect. Write your quiz answers on paper before you hit the Submit Button, in case you enter the wrong quiz password.)

1. What does RGB stand for in image computation? Red, Green, Blue
Raytrace, Greyhound, Blend
Random, Graphics, Boolean
none of the above.
2. Consider these python statement:
x, y = input("Enter the two values separated by a comma")
if x < 30 and y < 20:
    ans = 39
elif x < 30 and y < 30:
    ans = 49
elif x < 50 and y < 20:
    ans = 59
else:
    ans = 69 
If the user enters
40, 30
what value will variable ans have assigned to it?
39
49
59
69
None of the above.
3. The write() function enables a python program to write output to a file.
How many parameters must be passed to write() and what are their data types?
2 params, both strings
1 param, string
2 params, 1 string 1 int
2 params, both ints
none of the above
4. Consider this python statement
solow = string.capwords(raw_input("Enter your first name"))
Suppose the user types in
monty python
What will be the string value assigned to the variable solow?
"MONTY PYTHON"
"monty python"
"Monty python"
"Monty Python"
none of the above
What does this python statement do?:
nums = []
assigns nums the value empty string
assigns nums the value 0
assigns nums the value empty list
none of the above
6. Consider these two function definitions:
def poem(word, num):
    if(num == 1):
        print "A "+ word,
    else:
        print "is " + word

def main():
    first = "cookie"
    second = "ice cream"
    poem(first, 1)
    poem(second, 1)
What will be printed when we call main()?
"A cookie is cookie"
"A cookie is ice cream"
"A cookie A cookie"
"A cookie A ice cream"
7. Consider these statements:
change = [5, 10]
change.append(25)
What is the value of the variable change after the statements execute?
[5, 10, 25]
[25]
[5, 25]
[]
8. What is printed by the statements below?:
x = 0
for i in range(3):
    for j in range(2):
        x = x + j
print x
6
3
0
None of the above.
9. True or False? We can only place one function definition in each .py file. True
False
10.
import string
canned = ["hello there!", "Are you ok today?", "What's new?"]
x = string.split(canned[1])
What is x?
["hello", "there"]
["hello", "Are", "What's"]
["Are", "you"]
none of the above

To submit:

Press to submit your fully-completed quiz, or to reset all fields. Thanks!