Exercises
Variables
3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.
Exercise 1Passed
Create a variable called city holding the text Berlin, then print it.
Python
# your code here
A name, an equals sign, then the value in quotes.
city = "Berlin"
print(city)Exercise 2Passed
total starts at 50. Add 25 to it using the shorthand operator, then print it.
Python
total = 50
# add 25 to total
print(total)The shorthand for total = total + 25 is +=.
total = 50
total += 25
print(total)Exercise 3Passed
Print scratch, then remove the name with del, then print done.
Python
scratch = "temporary"
# print it, delete the name, then print done
del removes the name. The value goes once nothing points at it.
scratch = "temporary"
print(scratch)
del scratch
print("done")