
Fill in
Gluing Words Together
Text in Python is called a string (think of letters strung
together like beads). Strings can be in "double" or 'single'
quotes. Just match them.
+ glues strings together. This is called concatenation:
first = "Lantern"
second = "light"
print(first + second) # Lanternlight
print(first + " " + second) # Lantern light
Notice + adds no space for you. You add " " yourself.
* with a string and a number repeats it:
print("ho" * 3) # hohoho
print("-" * 10) # ----------
Assignment
Replace each ___ so the program prints:
~~~~~~~~~~~~~~~~
Welcome, Pip the Brave!
~~~~~~~~~~~~~~~~
bordershould be"~"repeated16times.greetingshould glue"Welcome, ",name," the ",titleand"!"together.
Replace each ___ so the program prints:
~~~~~~~~~~~~~~~~
Welcome, Pip the Brave!
~~~~~~~~~~~~~~~~
bordershould be"~"repeated16times.greetingshould glue"Welcome, ",name," the ",titleand"!"together.
main.py Python sleeping
Press Run to try your code, then Check to test it.