QMB3302 MIDTERM EXAM
QUESTIONS WITH CORRECT
ANSWERS
Which of the following operators represent proper means of
comparison? Select all that apply. -- Answer ✔✔ !=
==
>
<
>=
<=
Suppose you wanted to drive down to Tampa to watch the Rays play
baseball, but you would only go if the cheapest ticket cost less than 20
dollars. If so, then your function would output "Take me out to the
ballgame!" Tickets cost 26 dollars. Which function best illustrates this
statement? -- Answer ✔✔ Ticket = 26
if ticket < 20
print ("Take me out to the ball game!")
,Assuming this is a complete code chunk, and we expect to see output
printed after running this, why is the below code incorrect? (chose the
best answer, it may not be a great answer!)
If tom_brady == the goat:
print("The Buccs just won another Super Bowl") -- Answer ✔✔ The
variables are not defined
What type of error will you receive of you forget to indent your nested
if statement? -- Answer ✔✔ IndentationError
What is the purpose of an else statement? Choose the best answer. --
Answer ✔✔ It serves as a catchall function if if statement conditions
are not met
How Many outputs will the following code have?
mosquito = 1
While mosquito > 0:
print (mosquito)
mosquito = mosquito + 1
print(mosquito) -- Answer ✔✔ There are an infinite number of
mosquitos
A While Loop is most closely related to which other type of function or
statement (Choose the best answer) -- Answer ✔✔ "For" Loop
Within a "for" loop which line of code would you increase the number
within a variable? -- Answer ✔✔ NONE {See which one}
, Identify the parts of a for loop below:
for Iteration variable
in Iterables
:
Statement -- Answer ✔✔ (A) iteration Variable
(B) Iterables
(C) Statement
University of Florida President Kent Fuchs wanted to define a function
to count the student enrollment of the top three colleges: Liberal Arts,
Engineering, and Business. What two parts are MISSING in his code?
His code looks like this:
MISSING college_count(liberal_arts, engineering, business):
enrollment = liberal_arts + engineering + business
MISSING enrollment
Note that the function doesn't do anything yet... there are no values
for the 3 variables. -- Answer ✔✔ Def and return
Variable -- Answer ✔✔ A name, letter, or number that we assign VALUE
, we assign using "="
Strings -- Answer ✔✔ Terms such as "Hello" or "Sorry that didnt work"
Tuples -- Answer ✔✔ Lists that you CANT change,
QUESTIONS WITH CORRECT
ANSWERS
Which of the following operators represent proper means of
comparison? Select all that apply. -- Answer ✔✔ !=
==
>
<
>=
<=
Suppose you wanted to drive down to Tampa to watch the Rays play
baseball, but you would only go if the cheapest ticket cost less than 20
dollars. If so, then your function would output "Take me out to the
ballgame!" Tickets cost 26 dollars. Which function best illustrates this
statement? -- Answer ✔✔ Ticket = 26
if ticket < 20
print ("Take me out to the ball game!")
,Assuming this is a complete code chunk, and we expect to see output
printed after running this, why is the below code incorrect? (chose the
best answer, it may not be a great answer!)
If tom_brady == the goat:
print("The Buccs just won another Super Bowl") -- Answer ✔✔ The
variables are not defined
What type of error will you receive of you forget to indent your nested
if statement? -- Answer ✔✔ IndentationError
What is the purpose of an else statement? Choose the best answer. --
Answer ✔✔ It serves as a catchall function if if statement conditions
are not met
How Many outputs will the following code have?
mosquito = 1
While mosquito > 0:
print (mosquito)
mosquito = mosquito + 1
print(mosquito) -- Answer ✔✔ There are an infinite number of
mosquitos
A While Loop is most closely related to which other type of function or
statement (Choose the best answer) -- Answer ✔✔ "For" Loop
Within a "for" loop which line of code would you increase the number
within a variable? -- Answer ✔✔ NONE {See which one}
, Identify the parts of a for loop below:
for Iteration variable
in Iterables
:
Statement -- Answer ✔✔ (A) iteration Variable
(B) Iterables
(C) Statement
University of Florida President Kent Fuchs wanted to define a function
to count the student enrollment of the top three colleges: Liberal Arts,
Engineering, and Business. What two parts are MISSING in his code?
His code looks like this:
MISSING college_count(liberal_arts, engineering, business):
enrollment = liberal_arts + engineering + business
MISSING enrollment
Note that the function doesn't do anything yet... there are no values
for the 3 variables. -- Answer ✔✔ Def and return
Variable -- Answer ✔✔ A name, letter, or number that we assign VALUE
, we assign using "="
Strings -- Answer ✔✔ Terms such as "Hello" or "Sorry that didnt work"
Tuples -- Answer ✔✔ Lists that you CANT change,