Lecture
Printing Output 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.
Lessons in this chapter · Master the Fundamentals of Python
- 1. What is Programming and What Benefits Can You Gain from Learning It?
- 2. Coding and Viewing Your Results in Real-Time
- 3. Are There Levels in Programming Languages?
- 4. Features of Python and Simple Code Example
- 5. Reasons Why Python is Popular
- 6. Why is Indentation Important in Python?
- 7. Printing Output in Python
- 8. Getting User Input in Python
- 9. Multiple-choice quiz
- 10. Statements and Expressions
- 11. Predefined Reserved Words in Python - Keywords
- 12. How to Name Variables and Functions Sensibly
- 13. Explaining Code with Comments
- 14. What are Identifiers?
- 15. A Container for Data, Variables
- 16. Important Points When Assigning Values to Variables
- 17. Symbols for Performing Operations, Operators
- 18. Literals Representing Data
- 19. Coding Quiz - Return 10 Times the Given Number
- 20. Multiple-choice quiz
- 21. Fill-in-the-blank quiz
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help