Chapters
Python114 chapters

Exercises

Operators

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

Exercise 1

Print True when age is at least 18 and under 65, using a single chained comparison.

Python
age = 25
# print the chained comparison
Exercise 2

Two lists hold the same numbers. Print whether they are equal, then whether they are the same object.

Python
a = [1, 2, 3]
b = [1, 2, 3]
# print equality, then identity
Exercise 3

Add brackets so the expression gives 20 rather than 14.

Python
print(2 + 3 * 4)