COSC python - Final Exam Review
Questions and Answers
How many MB is 1GB? - Answer -1000MB
_______ phase of the SDLC process involves close interaction between the users and
developers. - Answer -Requirements Analysis
What is the computer's native language? - Answer -Machine Language
What is the IDE used for python? - Answer -Python IDLE
What is the result of the following expression?
10 - 5 % 2 + 3 // 2 * 2? - Answer -11
Given testAvg = 95.5 and letterGrade = 'A', the following print statement will result in an
error. How will you fix it?
print(testAvg + '/' + letterGrade) - Answer -print(str(testAvg) + '/' + letterGrade)
What is the output of the following code?
print(int(53.231) * ) - Answer -53
Assume gpa = 4.0 and major = "cosc". What is the output of the following statement?
print(gpa >= 3.5 and major.upper() == "cosc") - Answer -False
What is the missing input() statement in the following code that computes the degrees in
fahrenheit when degrees in celsius is input?
FREEZE = 32
FILL_IN_THE_MISSING_INPUT_STATEMENT
fahrenheit = (celsius * 1.8) + FREEZE
print("The degrees in Fahrenheit =", fahrenheit) - Answer -celsius = float(input("Enter
the value of degrees in Celsius: "))
What is the output of the following code?
y=0
if y > 3:
y=y+1
print("y is", y) - Answer -y is 0
What is the output of the following code?
if 4 // 2 >= 0:
, print(4 // 2)
if 4 % 2:
print(4 % 2)
else:
print(1) - Answer -2
0
What is the output of the following code?
if 4 // 2 >= 0:
print(4 // 2)
elif 4 % 2:
print(4 % 2)
else:
print(1) - Answer -2
What is the output of the following code?
grade = 75
if grade >= 80:
print("very good")
elif grade < 60:
print("not good")
else:
print("passed, but can do better") - Answer -passed, but can do better
Which line in the following program will cause an error?
1 num = 7
2 if num < 0 or > 100:
3 print("Out of range")
4 else:
5 print("Within range") - Answer -Line 2 (should be if num < 0 or num > 100:)
Given age = 18, convert the following conditional expression to appropriate selection
statement?
print("Eligible to vote!" if age >= 18 else "Not Eligible to vote!") - Answer -if age >= 18:
print("Eligible to vote!")
else:
print("Not Eligible to vote!")
What is the output of the following code?
x, y = None, 36
x = 100 if y > 50 else 200
print("x =", x, "y =", y) - Answer -x = 200 y = 36
What is the value of answer when x = 12, y = 3, z = 5?
answer = "Good" if x > y or x < z and y > z or z == y else "Bad"
print(answer) - Answer -Good
Questions and Answers
How many MB is 1GB? - Answer -1000MB
_______ phase of the SDLC process involves close interaction between the users and
developers. - Answer -Requirements Analysis
What is the computer's native language? - Answer -Machine Language
What is the IDE used for python? - Answer -Python IDLE
What is the result of the following expression?
10 - 5 % 2 + 3 // 2 * 2? - Answer -11
Given testAvg = 95.5 and letterGrade = 'A', the following print statement will result in an
error. How will you fix it?
print(testAvg + '/' + letterGrade) - Answer -print(str(testAvg) + '/' + letterGrade)
What is the output of the following code?
print(int(53.231) * ) - Answer -53
Assume gpa = 4.0 and major = "cosc". What is the output of the following statement?
print(gpa >= 3.5 and major.upper() == "cosc") - Answer -False
What is the missing input() statement in the following code that computes the degrees in
fahrenheit when degrees in celsius is input?
FREEZE = 32
FILL_IN_THE_MISSING_INPUT_STATEMENT
fahrenheit = (celsius * 1.8) + FREEZE
print("The degrees in Fahrenheit =", fahrenheit) - Answer -celsius = float(input("Enter
the value of degrees in Celsius: "))
What is the output of the following code?
y=0
if y > 3:
y=y+1
print("y is", y) - Answer -y is 0
What is the output of the following code?
if 4 // 2 >= 0:
, print(4 // 2)
if 4 % 2:
print(4 % 2)
else:
print(1) - Answer -2
0
What is the output of the following code?
if 4 // 2 >= 0:
print(4 // 2)
elif 4 % 2:
print(4 % 2)
else:
print(1) - Answer -2
What is the output of the following code?
grade = 75
if grade >= 80:
print("very good")
elif grade < 60:
print("not good")
else:
print("passed, but can do better") - Answer -passed, but can do better
Which line in the following program will cause an error?
1 num = 7
2 if num < 0 or > 100:
3 print("Out of range")
4 else:
5 print("Within range") - Answer -Line 2 (should be if num < 0 or num > 100:)
Given age = 18, convert the following conditional expression to appropriate selection
statement?
print("Eligible to vote!" if age >= 18 else "Not Eligible to vote!") - Answer -if age >= 18:
print("Eligible to vote!")
else:
print("Not Eligible to vote!")
What is the output of the following code?
x, y = None, 36
x = 100 if y > 50 else 200
print("x =", x, "y =", y) - Answer -x = 200 y = 36
What is the value of answer when x = 12, y = 3, z = 5?
answer = "Good" if x > y or x < z and y > z or z == y else "Bad"
print(answer) - Answer -Good