LearnFrenzy
Sign in Take a free test

Variables and Data Types · Predict the Output · Question 5

Truth values of common objects Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 5 Back to Exercise

What is the output of the following Python program?

main.py
print(bool(""), bool(" "), bool(0.0), bool([]), bool("False"), bool([0]))
  • A False False False False False False
  • B False True False False False True
  • C False True False False True True Correct
  • D True True False False True False
Correct Answer: Option C

Only empty and zero values are falsy. " ", "False" and [0] are all non-empty, so they are truthy.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links