# Creating a variable
name = "John"
# Outputting text and a variable
print("Hello, " + name + "!")
Hello, John!+ operator is used to concatenate (join) the pieces of text and the variable into a single string.# Creating a variable
name = "John"
# Outputting text and a variable using an f-string
print(f"Hello, {name}!")
Hello, John!name variable inside the message. The f at the beginning of the string tells Python to look for variables or expressions enclosed in curly braces ({}) and replace them with their values.