






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







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:
Signature:
months = ["Jan","Feb","Mar","Apr","May",
"Jun","Jul","Aug","Sep","Oct","Nov","Dec"] half = months[6] print(half.upper()) print(half[0]) print(months[-1].lower()) print(months[2:4]) start = 9 print(months[start-1]) term = 3 print(months[(start+term-1)%12])
Answer Key: JUL J dec [’Mar’, ’Apr’] Sep Dec
(b) Consider the following shell command and resulting output:
ls t* t.html test.png trash.html turtle2.py tc.htmk testSubprocess.py trashCans.csv turtle3.py tc.html th.html triangles.py
test: herd.py makeDirs* projectFiles/ i. What is the output for: ls t*.png
Answer Key: test.png
ii. What is the output for: ls t* | grep ".p" | sort
Answer Key: herd.py test.png
for col in range(mapShape[1]):
Answer Key: if elevations[row,col] <= 0: #Below sea level floodMap[row,col,2] = 1.0 #Set the blue channel to 100% else: #Above sea level floodMap[row,col,1] = 1.0 #Set the green channel to 100% #Save the image: plt.imsave(’floodMap.png’, floodMap)
i.
in1 = True in2 = False out = in1 and in
Answer Key: out = False
ii.
in1 = False in2 = False out = in1 and (in2 or not in1)
Answer Key: out = True
iii.
in1 = True in2 = False in3 = (in1 or in2) out = in1 and not in
Answer Key: out = False
iv.
in1 = False in2 = False
Answer Key: out1 = False out2 = False
(b) Design a circuit that takes a single input and always outputs True.
Answer Key:
tH = turtle.Turtle()
for i in range(10,255,10): tH.color((i,i,i)) tH.forward(i) th.left(90)
Answer Key: (b) What is the output:
#Collisions program import folium import pandas as pd
inF = input(’Enter CSV file name: ’) outF = input(’Enter output file: ’) df = pd.read_csv(inF)
map311 = folium.Map(location=[40.768731, -73.964915], tiles="Cartodb Positron",zoom_start=
for index,row in df.iterrows(): lat = row["LATITUDE"] lon = row["LONGITUDE"] name = row["TIME"] newMarker = folium.Marker([lat, lon], popup=name) newMarker.add_to(map311)
map311.save(outfile=outF)
import turtle
def main(): t = setUp() #creates a green turtle drawDecagon(t) #draws a decagon using the turtle conclusion() #prints goodbye
if name == "main": main()
Answer Key:
def setUp(): trey = turtle.Turtle() trey.color("green") return(trey)
def drawDecagon(t): for i in range(10): t.forward(100) t.right(360/10)
def conclusion():
print("Goodbye!")
#Sample program that loops from 10 down to 0 ADDI $s0, $zero, 10 #set s0 to 10 ADDI $s1, $zero, 2 #use to decrement counter, $s AGAIN: SUB $s0, $s0, $s BEQ $s0, $zero, DONE J AGAIN DONE: #To break out of the loop Values of $s0:
Answer Key: 10 8 6 4 2 0 (b) Write a MIPS program where the register, $s0 loops through the values: 1,2,3,4,
Answer Key:
#Program that loops from 1 upto 5 ADDI $s0, $zero, 1 #set s0 to 1 ADDI $s1, $zero, 1 #use to increment counter, s ADDI $s2, $zero, 5 #set s2 to use for comparison AGAIN: ADD $s0, $s0, $s BEQ $s0, $s2, DONE J AGAIN DONE: #To break out of the loop
(a)
//Mystery C++ #include
Answer Key:
#Asks for 5 numbers and prints total total = 0 for i in range(5): n = float(input(’Enter a number: ’)) total = total + n print("Total is", total)
(b) Write a complete C++ program that repeatedly prompts the user for a number until one that is strictly larger than 0 is entered. Your program should print out the final number the user entered.
Answer Key: //Checks input for positive number #include