Variables & Data Types

Strings

A string is a sequence of characters enclosed in quotes.

Creating Strings

single = 'Hello'
double = "World"
multi = """This is a
multi-line string"""

String Operations

Concatenation (Joining)

first = "Hello"
second = "World"
result = first + " " + second  # "Hello World"

String Methods

text = "hello world"
text.upper()      # "HELLO WORLD"
text.capitalize() # "Hello world"
text.replace("world", "Python")  # "hello Python"

F-Strings (Formatted Strings)

The modern way to include variables in strings:

name = "Alice"
age = 25
print(f"My name is {name} and I am {age} years old")
Visualizer
"Learning Python..."
assigned to
"Learning Python..."
message

Interactive Visualization

python
Loading...
Output
Run execution to see output...