Aan de slagGa gratis aan de slag

More than just true and false

Python has two boolean values available for you to use: True and False. Most commonly these boolean values are used to indicate that something is on or off, yes or no, or similar states. Additionally, many python types return "truthy" or "falsey" values depending on their condition when evaluated using the bool() function.

Deze oefening maakt deel uit van de cursus

Data Types in Python

Cursus bekijken

Oefeninstructies

  • Create an empty list called my_list
  • Print the truthiness of my_list.
  • Append the string 'cookies' to my_list
  • Print the truthiness of my_list.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create an empty list
my_list = ____

# Check the truthiness of my_list
____(____(____))

# Append the string 'cookies' to my_list
____.____('cookies')

# Check the truthiness of my_list
print(____(____))
Code bewerken en uitvoeren