- Information
- AI Chat
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.
Was this document helpful?
This is a Premium Document. Some documents on Studocu are Premium. Upgrade to Premium to unlock it.
Pratice Final 3
Course: Introduction to Computing I (ITI1120)
169 Documents
Students shared 169 documents in this course
University: University of Ottawa
Was this document helpful?
This is a preview
Do you want full access? Go Premium and unlock all 13 pages
Access to all documents
Get Unlimited Downloads
Improve your grades
Already Premium?
ITI1120 - Final Practice
Q1. What is the type for the parameters and the result in the following function
definition?
def test(x):
'''
Returns True if the value 0 is in x, and False otherwise
>>> test((1,2,0,4,5))
True
>>> test((1,5,6))
False
'''
res = False
for val in x:
if val == 0:
res = True
return res
Answers (choose one):
a) (str,str)->bool
b) (tuple)->bool
c) (tuple,int)->noneType
d) (str)-> int
Q2. What is the correct description of the following function?
def my_function(m):
'''(list) -> bool
Description:
>>> m = [[1,2,3],[4,5,6],[7,0,8]]
>>> my_function (m)
True
>>> m2 = [[0],[0,0,0]]
>>> my_function(m2)
False
'''
res = False
for rang_val in m:
for col_val in rang_val:
if col_val != 0:
res = True
break
return res
Answers (choose one):
a) Returns True if the matrix m (or list of lists) does not contain zeros
b) Returns True if the matrix m (or list of lists) contains at least one nonzero
element
Why is this page out of focus?
This is a Premium document. Become Premium to read the whole document.
Why is this page out of focus?
This is a Premium document. Become Premium to read the whole document.
Why is this page out of focus?
This is a Premium document. Become Premium to read the whole document.
Why is this page out of focus?
This is a Premium document. Become Premium to read the whole document.
Students also viewed
1 out of 13