/******************************************************************/

This document is subject to change.  Please monitor (refresh) regularly.

Please report any errors or omissions in this document: 
anne.dawson@gmail.com

This document is current at: Saturday 28th January 2012, 13:19 PT, AD

REFRESH THIS PAGE OFTEN 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
Notes on Academic Honesty (Thanks to Greg Baker, SFU)
Example of Academic Honesty Violation


Quiz 3 covers all topics covered in the course. 
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 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, exam or assessed lab
on the content of reading assignments, 
in-class assignments and homework assignments.




The format of Quiz 3 is as follows:



Quiz 3
======

(8% of final grade, 90 minutes)


Questions are based on the course notes and assignments.

Quiz 3 is closed-book: no books, notes, calculators, phones
or any other electronic equipment are allowed during quizzes.

Questions types may include: 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. 
All the topics are listed on the course schedule for the current semester.




Example Quiz 3 questions:



1.  What is the output of this Python 3 program?

x = 17 / 2 % 2 * 3**3
print (x)

A. 13.5
B. 16 
C. 54.0
D. none of the others



Answer: A. 13.5





 
2.  The following program will create the output shown beneath it.

Program:

print (7 > 10)
print (4 < 16) 
print (4 == 4) 
print (4 <= 4)  
print (4 != 4)  

Output: 

False
True
True
True
False

A. True
B. False



Answer: A. True






3.  What is the output of this Python program?


num1 = 5
if num1 >= 91:
    num2 = 3
else:
    if num1 < 6:
        num2 = 4
    else:
        num2 = 2
x = num2 * num1 + 1
print (x,x%7)



A.  21    3 
B.  21    0
C.  21    21
D.  none of the others



Answer B. 21   0







4. The three types of error that might be contained in a Python program are syntax, logic and run-time.

A. True
B. False


Answer: A. True






5. What is an algorithm?

A. a keyword of the Python language
B. a Python built-in function
C. a Boolean operator
D. a written description of the steps to solve a problem


Answer: D.  a written description of the steps to solve a problem.







6. A computer program is the implementation of an algorithm.

A. True
B. False


Answer: A. True





7. What is the data type of a value such as 3.142?


A. float
B. string
C. int
D. Boolean



Answer: A.  float





8. What is the data type of a value such as 3?

A. float
B. string
C. int
D. Boolean



Answer: C.  int









9. What is the data type of a value such as "anne was here"?

A. float
B. string
C. int
D. Boolean



Answer: B.  string









10.  What is the output when the following code is executed?

list1 = [2,4,6,8,10,12,14,16,18,20] 
print (list1[0:1],list1[5:7])

Answer:

A.  [2,4] [10, 12]
B.  [2,4] [12, 14]
C.  [2] [12, 14]
D.  [2] [10, 12, 14]




Answer: C.  [2] [12, 14]





11. (Short answer) Write the truth table for the not Boolean operator.

Answer:

value of A       not A
false            true
true             false




12. (Short answer) List four advantages of using functions in a program.

Answer:

divides the work into teams
makes software development more manageable
enables software reuse
avoids repetition
makes programs more understandable
easier to debug
easier to maintain
easier to test







13. (Short answer) The range built-in (always available) function has this syntax:

range([start,] stop [,step])

Explain this syntax.

Answer: 

The stop argument is required, the others are optional. 
Repeats to one minus the stop value, in steps of one, unless other step value specifed.







14. (Short answer)  Write two lines of Python 3 code that prints "error!" forever when run.

Answer: 

while 1:
	print ("error!")







15. (Short answer)  Give an example of a run-time error.

Answer:

attempt to divide by zero 







16. (Short answer)  Give an example of a syntax error.

Answer:

attempt to divide by a string object  







GPA
===
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!
AD
/************************************************************/
 

End of document

 

 


 




































Valid XHTML 1.0!

Valid CSS!