Python Code Evaluation Questions
Python Code Evaluation Questions
State Completed
Completed on sexta, 12 ago 2022, 18:22
Time spent 2 hours 54 minutes
Notas 7.00/8.00
Evaluate87.50 out of a maximum of 100.00
Question 1
Correct
Reached 1.00 out of 1.00
Mark question
Question text
Choose an option:
hello world
hello worldhello worldhello world
hello world * 3
A is incorrect because it ignores the effect of '* 3'. B and C are incorrect because '* 3' is not
a string, therefore it WILL not be concatenated with the string. D is correct because "* 3" is
understood by the Python compiler as a mathematical operation to print the message
3 times.
Question2
Correct
Reached 1.00 out of 1.00
Mark question
Text of the question
if = 10
print(if)
Choose an option:
a. 10
b. if
c. Error, because 'if' is not defined
Mark question
print(i)
Choose an option:
a. 1, 3
b. 1, 3, 5
c. 1, 5, 2
d. 1, 2
e. None of the above
Feedback
In a 'for loop' that iterates over a range, the first parameter denotes the starting index,
inclusive, the second parameter represents the stop index, exclusive, and the third parameter
it is the incremental value. In the statement of the interval of the question, it could be read as 'start i '
in 1, stop at 5 but not including 5, increase i by 2". A is the only possible solution that
attend.
Question4
Incorrect
Reached 0.00 out of 1.00
Mark question
findMax():
return max(5, 7)
Choose an option:
A is incorrect because max() is a built-in function in Python that returns the maximum of
elements. B is incorrect because it is not necessary for all function declarations
have parameters passed to the function, only when necessary. D is the only option
correct because to define a new function in Python, the 'def', which means 'define', must
to be in front of the function name.
Question 5
Correct
Achieved 1.00 out of 1.00
Mark question
set_ages = set(list_ages)
print(set_ages)
Choose an option:
Mark question
Given the following code that declares a new tuple named new_tuple:
["x","y","z","w"]
(‘w’,‘x’,’y’,’z’)
c. ERROR, because the tuple is immutable.
The letter C is correct because a tuple is immutable, which means its content cannot be modified.
manipulated. A, B, and C cannot be true because a tuple cannot be changed.
therefore no new element can be added.
Question 7
Correct
Reached 1.00 out of 1.00
Mark question
class ClownFish():
pass
fish = ClownFish()
isinstance(fish, ClownFish)
Choose an option:
a. True
b. False
Feedback
The variable name "fish" is created as an instance of the ClownFish class, so the
The isinstance() check against the ClownFish class should return true.
Question 8
Correto
Reached 1.00 out of 1.00
Mark question
class Fish():
pass
class ClownFish(Fish):
pass
fish = ClownFish()
isinstance(fish, Fish)
Choose an option:
a. True
b. False
Feedback