Home / Python Fundamentals / Strings & f-strings
Lesson 2 of 8

Strings & f-strings

Concept

Strings are text. You create them with quotes. f-strings let you embed variables directly inside text using curly braces — they start with f before the quote. This is how your deploy script prints status messages.
m3shdup/deploy-node.sh → Python equivalent
host = "204.168.250.88"
port = 64295

# f-string — the f before the quote is key
print(f"Deploying to {host}:{port}")
# Output: Deploying to 204.168.250.88:64295

# Without f-string (ugly, don't do this)
print("Deploying to " + host + ":" + str(port))

What's happening

The f prefix makes Python evaluate anything inside {}. Notice port is an int but f-strings convert it to text automatically. Without f-strings, you'd have to manually convert with str() and concatenate with +.

Quick Check — 3 questions

1. What does f"Score: {42}" produce?

2. What's the f before a string called?

3. What does f"Port {p}" do if p = 8080?