COMP204_S2020_final
.pdf
keyboard_arrow_up
School
McGill University *
*We aren’t endorsed by this school
Course
204
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
18
Uploaded by mayarogerss
December 2019
Supplemental Examination
Intro to Computer Programming for Life Sciences
COMP-204
March, 2020
EXAMINER:
Mathieu Blanchette
ASSOC. EXAMINER:
Yue Li
STUDENT NAME:
McGILL ID:
INSTRUCTIONS
CLOSED BOOK
X
OPEN BOOK
SINGLE-SIDED
PRINTED ON BOTH SIDES OF THE PAGE
X
MULTIPLE CHOICE
Note: The Examination Security Monitor Program detects pairs of students with unusually similar
answer patterns on multiple-choice exams. Data generated by this program can be used as admissible
evidence, either to initiate or corroborate an investigation or a charge of cheating under Section 16 of
the Code of Student Conduct and Disciplinary Procedures.
ANSWER BOOKLET REQUIRED:
YES
NO
X
EXTRA BOOKLETS PERMITTED:
YES
NO
X
ANSWER ON EXAM:
YES
X
NO
EXAM:
SHOULD THE EXAM BE:
RETURNED
X
KEPT BY STUDENT
PERMITTED
X
Specifications:
Two
double-side pages, 8.5 inches x 11 inches
NOT PERMITTED
CRIB SHEETS:
DICTIONARIES:
TRANSLATION ONLY
REGULAR
X
NONE
CALCULATORS:
NOT PERMITTED
X
PERMITTED (
Non-Programmable
)
ANY SPECIAL
INSTRUCTIONS:
•
Answer all questions on this exam.
•
This exam contains 22 questions on 18 pages.
•
If you need extra space, use the empty pages at the end of the exam.
Course: COMP-204 Intro to Computer Programming for Life Sciences
Page number: 1 / 18
Multiple choice questions (21 points).
Consider the following code
1
c l a s s
A() :
2
def
__init__( s e l f ,
B) :
3
s e l f .C = B
4
5
def
D( s e l f ) :
6
s e l f .C = 1
7
8
def
E() :
9
F = A()
1. (2 points) Which of A, B, C, D, E, or F is a method? Select ALL correct answers.
A
B
C
D
E
F
2. (2 points) Which of A, B, C, D, E, or F is an attribute? Select ALL correct answers.
A
B
C
D
E
F
3. (2 points) Which of A, B, C, D, E, or F is an object? Select ALL correct answers.
A
B
C
D
E
F
4. (3 points) Which line(s) of this program will trigger an error when it is executed. Select ALL correct
answers.
1
d = {
"Mathieu"
:
" Blanchette "
,
"Yue"
:
" Li "
,
15:[1 ,3 ,5 ,15]}
2
d [
"Yue"
]=
" L a n n i s t e r "
3
d [
"Mathieu"
][3]=
"X"
4
d [ 1 5 ]
= 10
5
d [ ( 3 , 8 ) ] += 1
A. Line 1
B. Line 2
C. Line 3
D. Line 4
E. Line 5
Course: COMP-204 Intro to Computer Programming for Life Sciences
Page 2
Page number: 2 / 18
5. (3 points) Assume s = "AGAGTC". Which of the following boolean expression(s) will evaluate to
True? Select
ALL
correct choices.
A. s[4] == "T"
B. s[-2:-1][0] == "T"
C. len([ x for x in s if x=="T"]) == 1
D. not ( len(s)==6 or s == set(s) )
E. s[0]<s[1] and s[1]<s[2]
6. (3 points) What would be the sensitivity and specificity of the following prostate cancer prediction
decision tree on the test data given below? Select
ONE
correct answers.
Age
PSA
Gender
Status
76
1.87
Male
Cancer
56
1.74
Female
Normal
59
1.72
Male
Normal
76
1.82
Male
Cancer
75
1.97
Male
Normal
73
1.45
Female
Normal
67
1.63
Male
Cancer
A. Sensitivity = 75%, Specificity = 66.67%
B. Sensitivity = 66.67%, Specificity = 75%
C. Sensitivity = 25%, Specificity = 33.33%
D. Sensitivity = 33.33%, Specificity = 25%
E. Sensitivity = 66.67%, Specificity = 25%
Course: COMP-204 Intro to Computer Programming for Life Sciences
Page 3
Page number: 3 / 18
7. (3 points) The functions below are supposed to determine whether a list of strings contains dupli-
cates (i.e. at least two elements that are equal). Which ones work correctly? Select ALL correct
functions.
1
def
contains_duplicates_A (L) :
2
r e t u r n
le n
(
s e t
(L) )>0
3
4
def
contains_duplicates_B (L) :
5
s = {x
f o r
x
in
L}
6
r e t u r n
le n
( s ) <
l en
(L)
7
8
def
contains_duplicates_C (L) :
9
d = {}
10
f o r
index ,
x
in
enumerate
(L) :
11
d [ index ]
= x
12
i f
l en
(d . keys () )!=
l en
(L) :
13
r e t u r n
True
14
r e t u r n
False
15
16
def
contains_duplicates_D (L) :
17
f o r
index ,
x
in
enumerate
(L) :
18
i f
x
in
L [ index +1:
l en
(L) ] :
19
r e t u r n
True
20
r e t u r n
False
21
22
def
contains_duplicates_E (L) :
23
f o r
index ,
x
in
enumerate
(L) :
24
i f
x
not
in
L [ index +1:
l e n
(L) ] :
25
r e t u r n
False
26
r e t u r n
True
A. contains_duplicates_A
B. contains_duplicates_B
C. contains_duplicates_C
D. contains_duplicates_D
E. contains_duplicates_E
Course: COMP-204 Intro to Computer Programming for Life Sciences
Page 4
Page number: 4 / 18
Short answer questions (35 points)
8. (2 points) What will be printed when this program is executed?
1
L = [5 ,
(3 ,6) ,
" Hello "
,
4]
2
output =
[ ]
3
f o r
i
in
range
(2) :
4
x = L . pop (0)
5
y = L . pop (0)
6
output . extend ( [ x ,
x ] )
7
p r i n t
( output )
9. (2 points) What will be printed when this program is executed?
1
def
f u n c t i o n ( x ,
y ) :
2
f o r
i
in
range
( y ) :
3
x += y
4
r e t u r n
x
5
6
x = 2
7
y = 3
8
z =
f u n c t i o n ( x , y )
9
p r i n t
( x , y , z )
10. (2 points) What will be printed when this program is executed?
1
def
f u n c t i o n ( x ,
y ) :
2
f o r
i
in
y :
3
x . extend ( y )
4
r e t u r n
x
5
6
x =
[ 2 ]
7
y =
[ 3 , 4 ]
8
z =
f u n c t i o n ( x , y )
9
p r i n t
( x ,
y ,
z )
Course: COMP-204 Intro to Computer Programming for Life Sciences
Page 5
Page number: 5 / 18
11. (3 points) What will be printed when this program is executed?
1
import
math
2
def
fun1 ( x ) :
3
i f
x <0:
4
r a i s e
ValueError
5
r e t u r n
math . s q r t ( x )
6
7
def
fun2 () :
8
fun1 (
-
2)
9
r e t u r n
fun1 (1)
10
11
a = b = c = 0
12
t r y
:
13
a = fun1 (4)
14
b = fun2 ()
15
c = fun1 (9)
16
except
ValueError :
17
p r i n t
(
"Problem"
)
18
p r i n t
(a ,
b ,
c )
12. (3 points) What gets printed when this program is executed?
1
L = [1 ,
6 ,
8 ,
2 ,
8]
2
p r i n t
(
[ x
f o r
x
in
L
i f
x >5]
)
3
p r i n t
(
{x
f o r
x
in
L
i f
x>5}
)
4
p r i n t
(
[ i
f o r
i , x
in
enumerate
(L)
i f
x >5]
)
13. (3 points) Write the function
dot_product
that takes as arguments two lists of integers of the same
lengths, and returns the sum of the products of each corresponding elements.
For example, dot_product([3, 1, 2], [4, 1, 3]) should return 19, because 3*4+1*1+2*3 = 19.
Make
your function as short as possible.
Course: COMP-204 Intro to Computer Programming for Life Sciences
Page 6
Page number: 6 / 18
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
A cursor can store
One or more rows
Zero rows
Only one row
Not more than 10 rows
arrow_forward
true/false
Both professor and assistant can create a new course (use case Create course) ( )
arrow_forward
PET ID
PET NAME
PET TYPE
PET AGE
OWNER
VISIT DATE
PROCEDURE
246
ROVER
DOG
12
SAM COOK
JAN 13/2002MAR 27/2002APR 02/2002
01 - RABIES VACCINATION10 - EXAMINE and TREAT WOUND05 - HEART WORM TEST
298
SPOT
DOG
2
TERRY KIM
JAN 21/2002MAR 10/2002
08 - TETANUS VACCINATION05 - HEART WORM TEST
341
MORRIS
CAT
4
SAM COOK
JAN 23/2001JAN 13/2002
01 - RABIES VACCINATION01 - RABIES VACCINATION
519
TWEEDY
BIRD
2
TERRY KIM
APR 30/2002APR 30/2002
20 - ANNUALCHECK UP12 - EYE WASH
The functional dependencies that I note are as follows:
Pet ID --> Pet Name, Pet Type, Pet Age, Owner
Pet ID, Visit Date --> {Visit Procedure} (the set of visit procedures), note the use of procedure codes that repeat, but are listed in their own column
So, Is there are other functional dependencies? If so, what are they? If not, why not? Do you believe it would help to create additional attributes during normalization? If so, what are they? If not, justify why it's not needed. Please help me understand this.
arrow_forward
Computer Science: What is the reason that sometimes much more space is reserved for a numeric field than any initial values stored.
arrow_forward
CASE BACKGROUND
Levi Landon owns a small lawn care business with three employees. He owns the lawn mowers, rakes, and weed whackers that are housed in a storage area at the back of his home. He currently keeps his records in a spiral-bound book. He has a page for his list of customers, and their information including when he first started to do their garden, and the size of their lawns. He has another section to keep track of payments. Levi usually requires payment on completion of the service, but this rarely happens and he has lost track of who owes him and how much.
Levi realizes that he is not as efficient as he could be in his record keeping and asks you to help him to track customer service dates, payments and lawn care revenue. He may want to get a loan to purchase some more equipment. He provides you with his book of customers, and payments and prices of the various lawn sizes.
To help Levi with the reporting requirements, you need to work with Customer, Payment, and Prices…
arrow_forward
8
File
Help
Tell me what you want to do
Home Insert Design Layout References Mailings Review View
iGET GENUINE OFFICE Your license isn't genuine, and you may be a victim of software counterfeiting. Avoid interruption and keep your files safe with genuine Office today.
Page 1 of 1
80 words
Accessibility: Investigate
CS309
CS309 ASSIGNMENT 9 - Word
A process description for "Pay Commission" is provided below:
For each COMMISSION EARNED
If EXTRA BONUS equals Y
|
-If PAYMENT TOTAL is greater than $80,000
Add 3% to COMMISSION PERCENT
Output SPECIAL LETTER
Output AWARD LIST
Else Add 2% to COMMISSION PERCENT
Output AWARD LIST
Else
If PAYMENT TOTAL is greater than $80,000
Add 1% to COMMISSION PERCENT
Output SPECIAL LETTER
Calculate COMMISSION COMMISSION PERCENT times PAYMENT TOTAL
Required:
Construct a Decision Table for the above process description.
delinki asylum
Get genuine Office
Learn more
F
+
+
X Q
X
100%
arrow_forward
Computer science
differences between Trigger and Stored Procedures in tabular form
arrow_forward
Unlimited tries
Assume
cur
is a
Cursor
object, the variable
name_input
references a string and the variable
price_input
references a
float
. Write a complete Python statement that uses a parameterized SQL statement to add a row to the
Inventory
table in which the value of the
name_input
variable is inserted in the
ItemName
column and the value of the
price_input
variable is inserted in the
Price
column.
arrow_forward
display SQL query with screenshots
arrow_forward
Python
arrow_forward
Input data validation refers to the process of ensuring that the data being used is accurate.
arrow_forward
Sample input file: (Assume all names and IDs in the list are unique and must stay unique.)
Introduction to Computer Programming Fundamentals CSCI 1 MBA 315 John Adams 111223333 100 87 93 90 90 89 91 Willy Smith Jr. 222114444 90 73 67 77 70 80 90 Phil Jordan 777886666 100 80 70 50 -60 90 100
Sample output file format: (Final report)
Course Name: Introduction to Computer Programming Fundamentals Course ID: CSCI 1 Class Location: MBA 315 Name ID Average Grade Adams, John 111-22-3333 91.5 A Smith Jr., Willy 222-11-4444 87.0 B Jordan, Phil 777-88-6666 -1 I
Student list print format to the monitor:
Name Average Grade Adams, John 91.5 A Smith Jr., Will 87.0 B Jordan, Phil -1 I
Student's detail format to the monitor:
Name: Adams, John ID: 111223333 Quiz Score: 100.00 Test Scores: 87.00 93.00 90.00 90.00 89.00 91.00 Average: 91.54 Letter Grade: A
Error messagesBad file name: Failed to open file.File with no data: Empty file.Adding student Error Adams is on the list, duplicated names are not…
arrow_forward
Computer science
a computer language for retrieving and manipulating data from a relational database
arrow_forward
Information technology The data type "Number" is an example of a data type for a data field in the record of an Access table.
True
False
arrow_forward
excel
Task Instructions
In the Column chart, switch the data shown In the rows
and columns.
arrow_forward
DATABASE SYSTEMS:
QUESTION
Do as directed
This describes the business process to publish an academic paper. The author submits a paper to an editor in chief of a journal. The editor first checks whether the paper fit the theme of the journal. If not, the editor rejects the paper. Otherwise, the editor in chief assigns the paper to a number of reviewers. The reviewers review the paper, and write a review. The review is sent to the editor in chief. The editor in chief then assesses the quality of the paper with the help of reviewers’ comments. If the quality is good, the paper will be accepted, and the author notified. Furthermore, the paper is forwarded to the publisher for publication. If the quality is bad, the editor rejects the paper.
Apply query to only access to compile the final decision to editor in chief and only visualized by author not reviewers
arrow_forward
python program
arrow_forward
CLASS TEST 1-Word
File
Home
Insert
Design
Layout
References
Mailings
Review
View
Grammarly
O Tell me uhat you want to do
2 Share
E
H
The figure above depicts how data is stored in a database. By indexing the
nodes in the database from 0 to the highest number:
a) Generate the node data array
b) Generate the left pointer array
c) Generate the right pointer array
arrow_forward
A social recreation club has a system to keep track of club members, committees
and activities.
Each club has a registration number and a title. Several members form committee.
Members are male and females. Each committee has a name, a unique number and
a date, which the committee has formed.
The system stores the members' unique identification number, name, address,
gender, birth date and club joining date. The club forms committees for different
activities.
A committee controls and organizes a number of activities, each of which has a
unique name, a unique number and description of the event. An event has event ID
and description of the event. An activity may consist of several events. Committee
publishes many online advertisements about the activities. Advertisement details
are ID and a title.
Draw the ER diagram to represent the above scenario
arrow_forward
Bias values are subject to iterative adjustment
True
False
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Related Questions
- A cursor can store One or more rows Zero rows Only one row Not more than 10 rowsarrow_forwardtrue/false Both professor and assistant can create a new course (use case Create course) ( )arrow_forwardPET ID PET NAME PET TYPE PET AGE OWNER VISIT DATE PROCEDURE 246 ROVER DOG 12 SAM COOK JAN 13/2002MAR 27/2002APR 02/2002 01 - RABIES VACCINATION10 - EXAMINE and TREAT WOUND05 - HEART WORM TEST 298 SPOT DOG 2 TERRY KIM JAN 21/2002MAR 10/2002 08 - TETANUS VACCINATION05 - HEART WORM TEST 341 MORRIS CAT 4 SAM COOK JAN 23/2001JAN 13/2002 01 - RABIES VACCINATION01 - RABIES VACCINATION 519 TWEEDY BIRD 2 TERRY KIM APR 30/2002APR 30/2002 20 - ANNUALCHECK UP12 - EYE WASH The functional dependencies that I note are as follows: Pet ID --> Pet Name, Pet Type, Pet Age, Owner Pet ID, Visit Date --> {Visit Procedure} (the set of visit procedures), note the use of procedure codes that repeat, but are listed in their own column So, Is there are other functional dependencies? If so, what are they? If not, why not? Do you believe it would help to create additional attributes during normalization? If so, what are they? If not, justify why it's not needed. Please help me understand this.arrow_forward
- Computer Science: What is the reason that sometimes much more space is reserved for a numeric field than any initial values stored.arrow_forwardCASE BACKGROUND Levi Landon owns a small lawn care business with three employees. He owns the lawn mowers, rakes, and weed whackers that are housed in a storage area at the back of his home. He currently keeps his records in a spiral-bound book. He has a page for his list of customers, and their information including when he first started to do their garden, and the size of their lawns. He has another section to keep track of payments. Levi usually requires payment on completion of the service, but this rarely happens and he has lost track of who owes him and how much. Levi realizes that he is not as efficient as he could be in his record keeping and asks you to help him to track customer service dates, payments and lawn care revenue. He may want to get a loan to purchase some more equipment. He provides you with his book of customers, and payments and prices of the various lawn sizes. To help Levi with the reporting requirements, you need to work with Customer, Payment, and Prices…arrow_forward8 File Help Tell me what you want to do Home Insert Design Layout References Mailings Review View iGET GENUINE OFFICE Your license isn't genuine, and you may be a victim of software counterfeiting. Avoid interruption and keep your files safe with genuine Office today. Page 1 of 1 80 words Accessibility: Investigate CS309 CS309 ASSIGNMENT 9 - Word A process description for "Pay Commission" is provided below: For each COMMISSION EARNED If EXTRA BONUS equals Y | -If PAYMENT TOTAL is greater than $80,000 Add 3% to COMMISSION PERCENT Output SPECIAL LETTER Output AWARD LIST Else Add 2% to COMMISSION PERCENT Output AWARD LIST Else If PAYMENT TOTAL is greater than $80,000 Add 1% to COMMISSION PERCENT Output SPECIAL LETTER Calculate COMMISSION COMMISSION PERCENT times PAYMENT TOTAL Required: Construct a Decision Table for the above process description. delinki asylum Get genuine Office Learn more F + + X Q X 100%arrow_forward
- Computer science differences between Trigger and Stored Procedures in tabular formarrow_forwardUnlimited tries Assume cur is a Cursor object, the variable name_input references a string and the variable price_input references a float . Write a complete Python statement that uses a parameterized SQL statement to add a row to the Inventory table in which the value of the name_input variable is inserted in the ItemName column and the value of the price_input variable is inserted in the Price column.arrow_forwarddisplay SQL query with screenshotsarrow_forward
- Pythonarrow_forwardInput data validation refers to the process of ensuring that the data being used is accurate.arrow_forwardSample input file: (Assume all names and IDs in the list are unique and must stay unique.) Introduction to Computer Programming Fundamentals CSCI 1 MBA 315 John Adams 111223333 100 87 93 90 90 89 91 Willy Smith Jr. 222114444 90 73 67 77 70 80 90 Phil Jordan 777886666 100 80 70 50 -60 90 100 Sample output file format: (Final report) Course Name: Introduction to Computer Programming Fundamentals Course ID: CSCI 1 Class Location: MBA 315 Name ID Average Grade Adams, John 111-22-3333 91.5 A Smith Jr., Willy 222-11-4444 87.0 B Jordan, Phil 777-88-6666 -1 I Student list print format to the monitor: Name Average Grade Adams, John 91.5 A Smith Jr., Will 87.0 B Jordan, Phil -1 I Student's detail format to the monitor: Name: Adams, John ID: 111223333 Quiz Score: 100.00 Test Scores: 87.00 93.00 90.00 90.00 89.00 91.00 Average: 91.54 Letter Grade: A Error messagesBad file name: Failed to open file.File with no data: Empty file.Adding student Error Adams is on the list, duplicated names are not…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage