Part A: Multiple Choice Questions For each questions circle the letter of the correct answer. You may give an optional reason or optionally show your work. If you mark the correct answer, the reason will not be considered. 5 points each. Up to 4 points for reason or work.
a = [["philadelphia", "chicago", "denver"],
"houston", "tulsa", "bismark", "cheyenne"]]
output = [ ]
for b in a:
for c in b:
output.append(c[2])
print("".join(output))
a. ["chicago", "tulsa"]
b. hheouih
abc def hijwhat is the output from this script?
fin = open("letters.txt", "r")
lines = [ ]
line = fin.readline( )
while line:
lines.append(line)
line = fin.readline( )
print(lines)
a. abcdefhij
b. abc def hij
fimage = open("image.ppm", "w")
fimage.fwrite("P3 5 5 255\n")
line1 = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"
line2 = "0 0 0 0 0 0 0 0 255 0 0 0 0 0 0\n"
fimage.fwrite(line1)
fimage.fwrite(line1)
fimage.fwrite(line2)
fimage.fwrite(line1)
fimage.fwrite(line1)
fimage.close( )
a. A blue dot on a black background.
value1 = float(input("Input a value in miles: ")
value2 = value1 * 12 * 5280
Which user defined method inputs a value in miles and returns
that value in inches?
a. def miles_to_inches( ):
return value2
b. def miles_to_inches( ):
value2 = value1 * 12 * 5280
return value2
c. def miles_to_inches(the_miles):
return the_inches * 12 * 5280
d. def miles_to_inches(the_miles):
return value2
d = {"name" : "Sally", "id" : 2345, "quiz_average" : 89}
how would the quiz average be printed?
class A:
def __init__(the_x, the_y):
self.x = the_x
y = the_y
which of the following is a local variable?Part B: Predict Output. Predict the output. 10 points each.
for i in range(0, 10):
print(" " * (10 - i), "==")
for i in range(0, 10):
print(" " * i, "==")
import json
arr = ["zero", "one", "two", "three"]
dictionary = { }
for i in range(1, 4):
dictionary[i] = arr[i]
s = json.dumps(dictionary)
print(s)
# Source code file b.py
class B:
def __init__(self, the_x, the_y):
self.x = the_x
self.y = the_y
def __str__(self):
return f"//{self.x}{self.y}//"
def augment(self):
self.x *= 2
self.y += 3
# Source code file test.py
from b.py import B
b = B(5, 6)
print(str(b))
print(b.x, b.y)
b.augment( )
print(b)
Part C: Find and Correct Errors. 15 points each.
d = {"CHF": 0.9936, "CHY": 6.3984, EUR; 0.8608 /
"GBP": 0.7516, "JPY": 109.05)
target currency = read_line "Enter desired currency: "
amount = readline("Enter amount to exchange: " + )
print("Currency amount in " + target_currency + /
"is" + round(d[target_currency * amount], 2)
import Json
fin.open("grade-records.json", "w")
json_string = fin.read( )
arr = loads(json_string)
# Enter desired first and last name.
desired_first_name = input(Enter desired first name: )
desired_last_name = input(Enter desired last name: )
# Print the GPA of the desired person.
grade_dict = ['A': 4, 'B': 3, 'C': 2, 'D': 1, 'F':= 0}]
for each d in arr
if desired_first_name = d["first_name"] && \
desired_last_name = d["last_name"]
credit_hours = d["credit_hours"]:
grade == d[grade]
grade_points = grade_dict[grade]
total_credit_hours += credit_hours
total_grade_points + = grade_points
gpa = total_grade_points \ total_credit_hours
print("GPA:" {round(gpa; 2)})
Here is the beginning of the JSON file grade-recores.json:[{"student_id": "148383847", "last_name": "Hoffman",
"first_name": "Raymond", "course_number": "ART104",
"course_name": "Creating Art", "credit_hours": 4,
"grade": "B"}, {"student_id": "148383847", "last_name":
"Hoffman", "first_name": "Raymond", "course_number":
"CHM127", "course_name": "Quantitative Analysis",
"credit_hours": 4, "grade": "A"}, ...