/******************************************************************/
This page is subject to change. Please refresh regularly.
This document is current at:
Thursday 2nd July 2020, 10:10 PT, AD
REFRESH/RELOAD THIS PAGE FOR LATEST VERSION
/******************************************************************/
CSCI120 QUIZ 3
==============
EXAM CONDITIONS APPLY FOR ALL QUIZZES
ELECTRONIC EQUIPMENT SHOULD BE SWITCHED OFF
AND PLACED AT THE FRONT OF THE ROOM.
Exam Rules
Academic Honesty Policy
Notes on Academic Honesty (Thanks to Greg Baker, SFU)
Example of Academic Honesty Violation
Quiz 3 covers ***all*** topics covered in the course
up to and including Searching.
*** The focus of Quiz 3 is strings, files and searching ***
Note: Students may be tested in a quiz or an exam
on the content of reading assignments and lab assignments.
All the topics are listed on the course schedule for the current semester.
CSCI120 QUIZZES
===============
There are three quizzes worth 20% in total:
Quiz 1 = 6%
Quiz 2 = 6%
Quiz 3 = 8%
The lowest scoring quiz will be dropped at the end of the course
so that the remaining 2 quizzes are worth 10% each.
The date of the quiz is shown in the course schedule and on C4.
See C4 for the latest details about Quiz 3.
Note: Students may be tested in a quiz or an exam
on the content of reading assignments and lab assignments.
The format of Quiz 3 is as follows:
Quiz 3
======
(8% of final grade, 60 minutes)
Questions are based on the course notes and assignments.
Quiz 3 is closed-book: no outside help, no Internet searchs,
no books, notes, calculators, phones
or any other electronic equipment are allowed during quizzes or exams.
Questions types may include (in any combination): multiple choice, short answer,
written questions, questions requiring interpretation of Python 3 code,
detection of errors and writing new Python 3 code.
Quiz 3 covers all topics covered in the course.
*** The focus of Quiz 3 is strings, files and searching ***
All the topics are listed on the course schedule for the current semester.
Example Quiz 3 questions:
1. Which of the following code fragments is correct?
A) print("Score : " + 91)
B) print("Score : " + int(91))
C) print("Score : " + str(91)
D) print("Score : " + str(91))
Answer: D
2. An escape sequence is used in programming languages
such as Python to designate a nonprintable character
such as a newline or a tab.
Which of the following characters starts an escape sequence?
A) e
B) %
C) \
D) #
Answer: C
3. Which of the following is an escape character?
A) n
B) 'n'
C) '\n'
D) "n"
Answer: C
4. Which of the following is an escape character?
A) 't'
B) 'n'
C) '\t'
D) "n"
Answer: C
5. A string can span multiple lines
if it is enclosed within which of the following?
A) '
B) "
C) '''
D) ''''
Answer C
6. In Python,
you cannot concatenate a string and an integer;
you must convert the integer to a string first.
A) True
B) False
Answer: A
7. If x is a string variable, which of the following Python statements is legal?
A) x * 3
B) x - 1
C) x / 2
D) x + 2
E) All of the above are illegal statements
Answer: A
8. Place these five software lifecycle phases into the correct order (performed first to last):
algorithm design, coding, maintenance, problem definition, testing
Answer: problem definition, algorithm design, coding, testing, maintenance
9. Python strings are mutable. True or False?
A) True
B) False
Answer: B
10. What, if anything,
is wrong with the following Python statement
which is intended to open file
C:\temp\file1.txt for reading?
file1 = open('C:\\temp\\file1.txt','r')
A) The file path should be enclosed in double quote marks.
B) There should be a single \ where there are two.
C) The text 'r' should be replaced with 'w'.
D) There is nothing wrong.
Answer: D
11. Predict the output:
f = open("test.dat","w")
f.write("Today is Saturday\nand the sun shines\nand I walk the dog\n")
f.close()
f = open("test.dat","r")
str1 = f.readline()
str1 = f.readline()
str2 = str1 + f.read(4)
print (str2)
Answer:
and the sun shines
and
12. (written Question)
Compare and contrast
the sequential search algorithm
with the binary search algorithm
Answer: see notes on the topic of Searching
13. What will be the output when the following code runs?
s = "When can I get rest?"
print(s[5])
print(s[6:12])
print(s[9:])
print(s[0:5].islower())
print(s.count("e"))
s = s.replace("e","X")
print(s)
print(s[20])
Answer:
c
an I g
I get rest?
False
3
WhXn can I gXt rXst?
index out of range
>>>
Grading
=======
Your attendance, conduct and progress are monitored throughout the course.
You may inspect your status report at any time using the online Gradebook.
The date of the quiz is shown in the course schedule - latest details on C4.
/************************************************************/
Good Luck!
annedawson.net
/************************************************************/
End of document