4. Variables pt. 2

  • You can reassign variables at any point in your program
  • You can perform arithmetic on numbers, and add string variables together

Tasks

  1. Copy the code below. What is happening to the message variable?
message = “Hello World”
print(message)
message = “Goodbye Cruel World”
print(message)
  1. Reassign the message variable again and print it out
  2. Change the messages printed in the program
print(message + “. I’m going soon”)
print(message + 10)
print(“Hello “ + message)
print(message + message)
  1. Add the code above. One of the lines produces an error.
  2. Disable the correct line using the # character at the start of the line
  3. Make sure the program runs without error
  4. Save and label your code

Extension

Can you multiply a word? What happens if you try?