Exercises
Variable Names
3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.
Exercise 1Passed
Rename the variables to snake_case so the code follows the usual Python convention.
Python
FirstName = "Grace"
itemsInCart = 3
print(FirstName, itemsInCart)Lowercase words joined by underscores.
first_name = "Grace"
items_in_cart = 3
print(first_name, items_in_cart)Exercise 2Passed
This shadows the builtin list, so the last line fails. Rename the variable and keep the output.
Python
list = [3, 1, 2]
print(sorted(list))
print(list((1, 2)))Name it after what it holds, such as numbers.
numbers = [3, 1, 2]
print(sorted(numbers))
print(list((1, 2)))Exercise 3Passed
Print how many reserved words Python has.
Python
# import keyword and print how many there are
keyword.kwlist is a list, so len() counts it.
import keyword
print(len(keyword.kwlist))