Mock Final Exam CSci 127: Introduction to Computer Science ...
Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York
10 December 2019
Exam Rules
? Show all your work. Your grade will be based on the work shown. ? The exam is closed book and closed notes with the exception of an 8 1/2" x 11" piece of paper
filled with notes, programs, etc. ? When taking the exam, you may have with you pens and pencils, and your note sheet. ? You may not use a computer, calculator, tablet, phone, or other electronic device. ? Do not open this exam until instructed to do so.
Hunter College regards acts of academic dishonesty (e.g., plagiarism, cheating on examinations, obtaining unfair advantage, and falsification of records and official documents) as serious offenses against the values of intellectual honesty. The College is committed to enforcing the CUNY Policy on Academic Integrity and will pursue cases of academic dishonesty according to the Hunter College Academic Integrity Procedures.
I understand that all cases of academic dishonesty will be reported to the Dean of Students and will result in sanctions. Name:
EmpID:
Email:
Signature:
(Image from wikipedia commons)
EmpID:
CSci 127 Mock Final, F19
1. (a) What will the following Python code print:
pioneers="Asimov%Isaac#Shelley%Mary#Gibson%William"
i. num = pioneers.count('%') num = num + pioneers.count('#') + 2
Output:
print(pioneers[len(pioneers)-num:].lower())
names = pioneers.split('#') ii. m = names[1]
print(m[-4]+'. '+m[:7])
Output:
for n in names:
iii.
print(n.split('%')[0][0])
Output:
(b) Consider the following shell commands:
$ pwd /Users/login/temp $ ls csBridge.png Elevations.csv
p25.py
p27.py
i. What is the output for: $ mkdir hwk $ mv *.p* hwk $ ls
Output:
ii. What is the output for:
$ cd hwk $ ls | grep ^p | wc -l
iii. What is the output for: $ pwd $ cd ../ $ pwd
Output: Output:
1
EmpID:
CSci 127 Mock Final, F19
2. (a) Consider the code:
import turtle thomasH = turtle.Turtle()
i. After the command: thomasH.color("#1B1B1B"), what color is thomasH?
black
red
white
gray
teal
ii. After the command: thomasH.color("#00AAAA"), what color is thomasH?
black
red
white
gray
teal
iii. Fill in the code below to change thomasH to be the color white:
thomasH.color("#
")
iv. Fill in the code below to change thomasH to be the brightest purple:
thomasH.color("#
")
(b) Fill in the code to produce the output on the right:
i. for i in range(
):
print(i, end=" ")
Output: 0123456789
Output:
ii. for j in range(
,
,
):
print(i, end=" ")
-2 0 2 4 6
Output:
import numpy as np import matplotlib.pyplot as plt iii. im = np.ones( (10,10,3) )
im[:, :5,:] = 0 plt.imshow(im) plt.show()
Output:
import numpy as np import matplotlib.pyplot as plt iv. im = np.ones( (10,10,3) )
im[0::
, 2::
plt.imshow(im)
plt.show()
, :] = 0
2
EmpID:
3. (a) What is the value (True/False): in1 = False
i. in2 = True out = in1 or in2
in1 = True ii. in2 = True
out = not in1 or (in2 and not in2)
in1 = True iii. in2 = True or not in1
in3 = in1 or in2 out = in1 and not in3
CSci 127 Mock Final, F19
True True True
False False False
iv. in1 = True in2 = False in3 = False
True
(b) Draw a circuit that implements the logical expression: ((in1 or in2) and (not in2))
False
(c) Fill in the circuit that implements the logical expression: ((in1 or (in1 and not in2)) and (in3 or not in3))
3
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- part 2 module 1 logic statements negations quantifiers
- propositional logic university at buffalo
- part i programming in java princeton university
- cs 341 foundations of computer science ii prof marvin
- chapter 2 boolean algebra and logic gates
- forensic science unit 6 norfolk public schools
- 1 1 propositions and logical operations texas a m university
- predicate logic and quantifiers
- 5 1 boolean expressions santiago canyon college
- using the ti 92 calculator as a tool for illustrating