Lecture

How to Display Data on the Screen in Python

The print() function displays the data inside the parentheses ( ) on the screen, just like the English word "print."


How to Use It?

Simply enter the data you want to display inside the parentheses!

Using the print() Function
print("Python") # Displays the string "Python" print(123) # Displays the number 123 message = "CodeFriends" # Assigns "CodeFriends" to the variable message print(message) # Displays the value stored in the variable message

Displaying Multiple Data at Once

You can display multiple items simultaneously using the print function and separating them with commas (,).

Each item separated by a comma is automatically distinguished by a whitespace.

Displaying Multiple Data
name = "CodeFriends" age = 20 print(name, "is", age, "years old") # Displays "CodeFriends is 20 years old"

Coding Practice

Enter print(4 / 2) in the practice code editor.

"print(4 / 2)" outputs the result of dividing 4 by 2. In Python, division is done using a forward slash (/), and the result is returned as a floating-point number.

Therefore, the result of 4 / 2 is the floating-point number 2.0 rather than the integer 2.

Lecture

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result