All quizzesEasy
Core Concepts — Series 2
Preview — 3 of 10 questions
What is the output of the following code?
javascript
s = "ab"
print(s * 3)
print(s + "cd")
print(s * 0)
print("py" "thon")Aababab, abcd, (empty string), python
Bababab, abcd, ab, python thon — s * 0 returns the original string unchanged, and adjacent literals insert a space.
Cababab, ab+cd, (empty string), pythhon
DTypeError: can't multiply sequence by non-int on s * 0
What is the output of the following code?
javascript
def min_max(numbers):
return min(numbers), max(numbers)
result = min_max([3, 1, 4, 1, 5])
print(result)
print(type(result))
lo, hi = min_max([3, 1, 4, 1, 5])
print(lo, hi)A1, 5, <class 'tuple'>, 1 5 — result is printed as two separate values, not as a single tuple.
B(1, 5), <class 'tuple'>, 1 5
C(1, 5), <class 'list'>, 1 5
DTypeError: min_max() takes 1 positional argument but a tuple was expected
What is the output of the following code?
javascript
data = {"a": 1, "b": 2}
print("a" in data)
print(1 in data)
print(1 in data.values())
text = "hello world"
print("wor" in text)ATrue, True, False, True
BFalse, False, True, True
CTrue, False, True, True
DTrue, False, False, False
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.