Chapters
Python114 chapters

Exercises

Booleans

3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.

Exercise 1

Print a message only when the list is empty, using truthiness rather than len().

Python
items = []
# print "nothing here" when items is empty
Exercise 2

name is empty. Print Anonymous instead, in one line, using or.

Python
name = ""
# print name, or Anonymous when it is empty
Exercise 3

Count how many scores are above 60 and print the number.

Python
scores = [45, 80, 62, 95]
# print how many are above 60