This Python Output lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.
print can take several values. It separates them with a space and ends with a new line unless you change the ending.
Use an f-string when the sentence has values mixed into the words.
Example 1: Start here
An f-string starts with the letter f before the quote.
city = "Chennai" # text
score = 82 # a whole number
print("City:", city) # a comma prints each value, with a space between
print(f"Score is {score}") # the f before the quote fills in the braces
Example 2: Label a value
The label and the value are two arguments. print puts a space between them.
city = "Chennai" # text
print("City:", city) # a comma prints each value, with a space between
Example 3: Use an f-string
The f before the quote lets you drop the variable inside braces.
score = 82 # a whole number
print(f"Score is {score}") # the f before the quote fills in the braces
Example 4: Print several values
print accepts as many values as you need.
print("Batch", 12, "open") # a comma prints each value, with a space between
