Pythondex
Learn Python

Print In Python

Printing is a fundamental aspect of programming that allows you to display information on the screen.

Syntax


print("message to print")

To print in python we use the print() function, Inside the function we put the message to print enclosed in quotes.

Basic Usage

print("Hello Developers")

Click on the Run Code button to the run the code and you should see Hello Developers as output. It is because inside the print function we put Hello Developers.

Printing Variables

A variable is like a container which we use to store information like numbers, words etc. We can print the information inside the variables using the print().

Example


name = "Jason"
age = 18

print(name)
print(age)

The above program will print Jason and 18 as we have given the variable name in the print statement it will print the information stored in the variable.

Printing Variables With Labels

We don’t know what it printed because it doesn’t have a label. So, we can place text in the first part of the print function, followed by the variable.

Example


name = "Jason"
age = 18

print("Name: ", name)
print("Age:", age)