Editor

Predict the Output: Truthy or Falsy?

Beginner · Predict the output · from Python Variables and Data Types: A Practical Introduction

From the lesson: Python Variables and Data Types: A Practical Introduction

Imagine you're shipping a package. You fill out a label that asks for the weight. You write "heavy" instead of a number. The shipping system crashes - it can't calculate a price from the word "heavy."

Read the lesson

Without running the code, predict what each line will print. Then run it to check your answers.

Write your predictions as comments, then click Run to verify.

print(bool("")) # Your prediction:
print(bool(0)) # Your prediction:
print(bool("False")) # Your prediction:
print(bool(None)) # Your prediction:
print(bool(-1)) # Your prediction:
print(bool(" ")) # Your prediction:

More Variables and Data Types exercises

All Python exercises · 50 practice problems · Python Fundamentals quiz