LearnFrenzy
Sign in Take a free test

Python Built-in Functions · Exercise 2 of 4

Python Built-in Functions Predict the Output

  • 15 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Read each Python program and choose what it prints. Every program was run on Python 3, so the answers are the real output.

Question 11 Medium

What is the output of the following Python program?

main.py
print(list(map(max, [1, 9, 3], [4, 2, 8])), list(filter(None, [0, "a", "", 5, None])), list(map(str.title, ["asha rao"])))
A [4, 9, 8] ['a', 5] ['Asha Rao']
B [9, 8] ['a', 5] ['Asha rao']
C [4, 9, 8] [0, '', None] ['Asha Rao']
D [1, 9, 3] ['a', 5] ['ASHA RAO']
Question page & discussion
Question 12 Easy

What is the output of the following Python program?

main.py
print(callable(len), callable("text"), callable(lambda: 0), callable(int), callable(str.upper))
A True False True False True
B True True True True True
C True False False True False
D True False True True True
Question page & discussion
Question 13 Medium

What is the output of the following Python program?

main.py
r = range(0, 20, 3)
print(len(r), r[2], r[-1], 9 in r, 10 in r, r[1:3])
A 7 6 18 True False [3, 6]
B 6 6 18 True False range(3, 9, 3)
C 7 9 20 True True range(3, 9, 3)
D 7 6 18 True False range(3, 9, 3)
Question page & discussion
Question 14 Medium

What is the output of the following Python program?

main.py
print(format(1234.5, ",.2f"), repr("hi"), str(3.0), format(0.25, "%"), format(5, "03d"))
A 1234.50 hi 3 25% 005
B 1,234.50 'hi' 3.0 25.000000% 005
C 1,234.50 'hi' 3.0 25% 5
D 1,234.5 'hi' 3.0 0.25% 005
Question page & discussion
Question 15 Medium

What is the output of the following Python program?

main.py
print(int("  42\n"), float(" 3.5 "), int("0x1f", 16), bool("0"), bool(int("0")))
A 42 3.5 31 False False
B ValueError
C 42 3.5 1f True False
D 42 3.5 31 True False
Question page & discussion
Up next · Exercise 3Find the Error10 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links