Strings are a common data type which is used to store and manipulate text
Once you write a string, it can’t be changed—just like getting inked. If you want to “change” it, you actually create a brand-new string.
🗨️ "Python, I need a remix!"
✅ Make a new version; the original stays untouched.
Every character in a string has a spot—starting from 0, not 1!
So in "Hello"
"H" is at position 0,
"e" is at 1,
and so on...
That’s how Python knows where everything is. Like track numbers on an album.
To make a string in Python, just wrap it in quotes:
'Single quotes'
"Double quotes"
'''Triple quotes''' for big, multi-line texts (like poetry or song lyrics)
Yes, Python is totally cool with different styles—as long as you’re consistent!
Typical Ways to Create Strings
Single or Double Quotes
Single Quotes
Double Quotes
Triple Single Quotes:
Triple single quotes are used for multi-line strings or strings that span multiple lines.
Triple Double Quotes:
Like triple single quotes, triple double quotes can be used for multi-line strings.
Imagine you’re texting Harry Potter a secret spell... but every time you try to type \n for "newt" he thinks you mean newline. Annoying, right?
Enter: raw strings — your spell-safe zone.
A raw string tells Python:
“Hey, don’t mess with my backslashes. Take everything I type literally.”
Normally, Python treats \n as a newline, \t as a tab, etc.
But with a raw string, written like r"your\text\here", Python keeps the slashes as-is.
"It’s like telling Python, 'No filters, no edits — just the raw footage.' Like a celebrity dropping the unedited version of their album."
You'll need to create a file which has some strings defined!! You'll need to:
Create a variable holding a string that is a song title (using double quotes)
Create a variable which holds a quote from a book or movie (using single quotes)
Create a variable which holds a RAW STRING (some fun ascii text)
Create a variable which contains a string with double quotes in it
Create a variable which contains a string with singe quotes in it
Now Your Program Must Print All Of Your Variables
Displaying Formatted Strings (f-strings) (f'...' or f"...")
Introduced in Python 3.6, f-strings allow you to embed expressions inside string literals, using curly braces {}.
You can see these examples where we display variables right inside a string!!
S.H.I.E.L.D. just discovered Loki wiped all the Avengers’ ID badges. It’s chaos in the tower. No one can get through the cafeteria doors.
Your mission: Rebuild the entire Avengers ID system — using f-strings in Python.
Create Variables for name, age,
Fill them with information from your favorite marvel character
Use fstrings and { } to print them inside print statements
Here's an example of how you can create them and fill them with info! Just remember:
print(f" you can print a string with a {variable_name} just like this")
S.H.I.E.L.D. wants a whole batch. Make three separate hero profiles, each with their own name, age, power, catchphrase or other information!!
We have some very strange options in Formatted Strings, many of which you'll need to look up. Below are JUST A FEW!!
Left-align (:<)
Aligns text to the left within a specified width.
Right-align (:>)
Aligns text to the right within a specified width.
Center-align (:^)
Centers text within a specified width.
Custom Padding Character
You can specify a custom character to pad with (e.g., *).
Mini-Task: Minion Alignment
Can you figure out how to use the alignment?? You can look this up and see what you can come up with!!!
You’ve been hired as a digital sign designer for the world’s coolest pop-culture theater. Your job is to make three marquee signs promoting upcoming shows, movies, or video game tournaments.
Your signs must include:
A top and bottom border line made with a repeated character (*, #, ~, =, etc.)
A centered title line using :^width
A right-aligned location using :>width
A left-aligned or dotted time line using :<width or :.<width
Optional: Add extra flair (custom padding characters, emojis, or ASCII art)
Rules:
Use f-strings or format()
Use at least 3 different alignment styles in your code
Keep your marquee between 40–60 characters wide
Let's start out this activity by typing the following code...
Fixed Decimal Precision (:.nf)
Formats floating-point numbers with width m and n decimal places.
Specify Width and Precision (:m.nf)
Formats floating-point numbers with width m and n decimal places.
Thousands Separator (:,)
Formats numbers with commas as thousands separators.
Now, let's finish the code, which helps us see how the formatting goes!
Add one more line for “Snack Revenue” with thousands separator.
Try aligning the numbers right-aligned in a column using :>15 so they line up perfectly.
String Concatenation with + Operator
You can concatenate multiple strings using the + operator.
String Repetition with * Operator
You can repeat a string multiple times using the * operator.
You’ve been hired as a catchphrase consultant for a brand-new animated cartoon series.
Your job is to create dramatic character intros by combining and repeating parts of strings.
Create 3 string variables for each character:
Each character should have a unique name, power, and catchphrase
Get weird and creative (pop culture references are encouraged!)