CSC 111 Quiz 2, Fall 2006

Submit by Tues October 3 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. The syntax rule for a definite (for) loop starts
for <variable> in <sequence>:
Which of the following statements is true?
<variable> can be any identifier that is not reserved.
<sequence> can be [1,-5,3]
in is a reserved word
all of the above.
none of the above.
2. If we call the range() function this way:
range(3,10,3)
which list will it return?
[3,10,3]
[3,3,3]
[3,6,9]
[3,6,9,12]
None of the above.
3. Suppose we have the following two python statements:
path = "public_html/"
file = "index.html"
filename = path+file
What is the value stored in variable filename?
"pathfile"
"filepath"
"public_html/index.html"
"public_html/file"
none of the above
4. The ASCII table assigns numbers to every variable
character
function
none of the above
5 and 7 are integers. What does the Python interpreter compute as 7%5? 35
2
0
7.5
6. Consider the python decision statement
x = [2,3,4]
if x[2]==4:
    print "four"
else:
    print "three"
What will be printed?
four
three
two
7. The syntax rule for a definite (for) loop starts
for <variable> in <sequence>:
Which of the following statements is true about <sequence>?
It must be a list of numbers.
It cannot be a list of strings
It can be a list of numbers or strings.
8. Consider the guidelines for pair programming given in the pair programming review on the syllabus for the week dated Sept 28. Which of the following is *not* in the guidelines:
Warm cookies and cold milk are good for you.
Don't hit your partner.
Play fair.
Pair programmers have supple wrists.
Say you're sorry when you hurt somebody while moving furniture.
Wash your hands of skepticism before you start.
9. True or False? The string.split() function returns a list of strings. True
False
10. Consider the statements:
canned = ["hello", "Are you ok today?", "What's new?"]
num = random.randrange(0,len(canned))
response = raw_input(canned[num])
What values are passed to randrange()?
0, 2
0, 3
1, 3
none of the above

To submit:

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