Printing and Declaring Variables in Python

Python! One of the most used programming languages particularly in the field of data science. As a very flexible programming language, let’s start off with trying to declare and print given variables in Python.

Example code:

name = "John Cena"


John Cena

Above, we declare the variable name and assign the string “John Cena” to the name. Then we use the print command to print the string “Hello” on one line, and then we also print “John Cena” by recalling back to the name variable that contains “John Cena”.

Although this is correct, we can make the output look better. Instead, we can code:

name = "John Cena"
print(f"Hello {name}.")


Hello John Cena.

So, instead of using two print commands to print out two separate strings on separate lines, we used one print command with an f-string to combine both “Hello” and “John Cena”. F-strings are a way to format strings as they include expressions in braces.