Lecture
How to Display Data on the Screen in Python
The print()
function, which means "to output" in English, displays the data inside parentheses ( )
on the screen.
How Do You Use It?
Simply input the data you want to output inside the parentheses, and that's it!
Using the print() Function
print("Python") # Outputs the string "Python" print(123) # Outputs the number 123 message = "CodeFriends" # Assigns "CodeFriends" to the variable message print(message) # Outputs the value stored in the variable message
Printing Multiple Data Items at Once
By using a comma (,)
inside the print function, you can output multiple items simultaneously.
Each item separated by a comma is divided by a whitespace.
Printing Multiple Data Items
name = "CodeFriends" age = 20 print(name, "is", age, "years old") # Outputs "CodeFriends is 20 years old"
Coding Practice
Enter print(4 / 2)
into the practice code editor.
"print(4 / 2)" outputs the result of dividing 4 by 2. In Python, division is performed using the slash symbol(/)
, and the result is returned as a floating-point number.
Thus, the result of 4 / 2 is a floating-point number 2.0
instead of an integer 2
.
Mission
0 / 1
Complete the function to display data on the screen in Python.
('Hello, World!')
print
display
show
output
Lecture
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Run
Generate
Execution Result