- You can reassign variables at any point in your program
- You can perform arithmetic on numbers, and add string variables together
Tasks
- Copy the code below. What is happening to the message variable?
message = “Hello World”
print(message)
message = “Goodbye Cruel World”
print(message)
- Reassign the message variable again and print it out
- Change the messages printed in the program
print(message + “. I’m going soon”)
print(message + 10)
print(“Hello “ + message)
print(message + message)
- Add the code above. One of the lines produces an error.
- Disable the correct line using the # character at the start of the line
- Make sure the program runs without error
- Save and label your code
Extension
Can you multiply a word? What happens if you try?