Text (strings)
Anything inside quotes is called text in programming (the technical word is string). Python can do some surprisingly fun things with text.
Join text together: +
Section titled “Join text together: +”The + sign glues two pieces of text together:
Inputs (for input())
One value per line — read in order by input().
Notice: if you don’t leave a space after "Hello,", the words come out stuck together. Try it! 🙂
Repeat text: *
Section titled “Repeat text: *”The * sign repeats text as many times as you want:
Inputs (for input())
One value per line — read in order by input().
"=" * 30 — thirty equals signs in a row. A great trick for drawing tables and frames.
Single or double quotes?
Section titled “Single or double quotes?”Either works — Python doesn’t care:
print("Hello")print('Hello')But if the text has a quote inside it, pick a different one for the outside:
Inputs (for input())
One value per line — read in order by input().
Missions
Section titled “Missions”Glue it together
+10 XP ✓ CompletedUse + to join two pieces of text so the screen shows exactly Python rocks.
Inputs (for input())
One value per line — read in order by input().
Laughter generator
+10 XP ✓ CompletedUse * to print hahahahaha to the screen — but write the word "ha" only once!
Inputs (for input())
One value per line — read in order by input().
Framed name
+15 XP ✓ CompletedFrame your name between lines made of = signs — a line on top, your name in the middle, a line below.
Inputs (for input())
One value per line — read in order by input().
Next lesson: numbers and math — Python is far more powerful than your pocket calculator. Continue →