Professional Documents
Culture Documents
ONLY)
COURSE: ECOR 1041 AB FACILITATOR NAME: GIANA SAMY
It is most beneficial to you to write this mock midterm UNDER EXAM CONDITIONS. This means:
• Complete the exam in 2.5 hour(s).
• Work on your own and attempt every question.
• Keep your notes and textbook closed.
• Do not use your computer, Wing101, PythonTutor or the Python Shell while solving
the questions. You may use a non-programmable calculator.
After the time limit, go back over your work with a different colour or on a separate piece of paper and
try to do the questions you are unsure of. Record your ideas in the margins to remind yourself of what
you were thinking when you take it up at PASS.
The purpose of this mock exam is to give you practice answering questions in a timed setting and to help
you to gauge which aspects of the course content you know well, and which are in need of further
development and review. Use this mock exam as a learning tool in preparing for the actual exam.
Please note:
Complete the mock exam before attending the take-up session. During the session you can work
with other students to review your work.
Often, there is not enough time to review the entire exam in the PASS workshop. Decide which
questions you most want to review – the Facilitator may ask students to vote on which
questions they want to discuss in detail.
Facilitators will not distribute an answer key for mock exams . The Facilitator’s role is to help
students work together to compare and assess the answers they have. If you are not able to
attend the PASS workshop, you can work alone or with others in the class.
PASS worksheets are designed as a study aid only for use in PASS workshops. Worksheets may
contain errors, intentional or otherwise. It is up to the student to verify the information
contained within by attending the PASS workshop.
Take-up Session #1: Monday, October 16th 11:05 am – 12:55 pm (ML 402)
1. How many total function calls are made in the script below (excluding the print statements)?
2. If we ran the following script, which of the following would be the correct output?
a) b) c) d) e) None of these
1 1 0 1
12 12 01 21
123 123 012 321
1234 1234 0123 4321
12345 12345 01234
MOCK EXAM (FOR PRACTICE
ONLY)
COURSE: ECOR 1041 AB FACILITATOR NAME: GIANA SAMY
c) The return statement should always be at the first thing in the body of the function.
4. Identify the line that will cause an error (either syntax or logic) in the following function body.
return curr_smallest
x = -4
x = manipulate(x)
a) 4 b) -4 c) None d) 0 e) None of these
MOCK EXAM (FOR PRACTICE
ONLY)
COURSE: ECOR 1041 AB FACILITATOR NAME: GIANA SAMY
else:
if core == 'A':
curr_rank = 'B'
else:
curr_rank = 'B'
return curr_rank
x = 'a'
y = 97
y -= y - 1
x += len(x) * x + y * x
x = -1
x = negate(negate(x) + 1)
a) 0 b) 1 c) -1 d) None e) None of these
MOCK EXAM (FOR PRACTICE
ONLY)
COURSE: ECOR 1041 AB FACILITATOR NAME: GIANA SAMY
9. When performing unit testing on your function you should call the function
from two different files then compare the results.
a) True
b) False
10. Assert statements are used in unit testing to confirm that the expected result is equal to the actual
result.
a) True
b) False
13. Given the following description, select the best function header.
"""
Return the maximum value out of a, b and c.
"""
1. Here is an incomplete transcript on the Python shell. Write the values that will be displayed
after the final expression before the line is evaluated (assume all the statements they are
applied sequentially, right after one another). If nothing is displayed, write ‘nothing’. If an error
is produced, write ‘error’.
>>> float(int(1.25))
____________________________
>>> lst.append(0)
>>> lst
____________________________
____________________________
>>> lst[5]
____________________________
____________________________
MOCK EXAM (FOR PRACTICE
ONLY)
COURSE: ECOR 1041 AB FACILITATOR NAME: GIANA SAMY
>>> x = 10
>>> y = 1.0
>>> z += x
>>> y = x / 5 * (z % y)
____________________________
____________________________
____________________________
____________________________
1. Write a function named name_list that prompts the user to enter one name at a time, then when
the user enters “Stop” it returns a list of all the names entered.
For example:
>>>name_list()
…[Giana, Ben]
MOCK EXAM (FOR PRACTICE
ONLY)
COURSE: ECOR 1041 AB FACILITATOR NAME: GIANA SAMY
“””Return a list of booleans that indicates whether each individual name exceeds the given length.
“””
MOCK EXAM (FOR PRACTICE
ONLY)
COURSE: ECOR 1041 AB FACILITATOR NAME: GIANA SAMY
Bonus questions:
3. Write a function called unique that will accept a list of integers, which may contain duplicate values,
and returns a list with the duplicates removed. Your function may not use any built-in python
functions and must follow the FDR. If you choose, you may implement a helper function that your
unique function can call.
Note: The order of the values that appear in the list without duplicates is irrelevant, as long as all
of them appear.
Here’s an example:
"""
>>> unique([1, 2, 3, 5, 2, 4, 4, 1])
>>> [1, 2, 3, 5, 4]
"""