Using print()
Use print() whenever you want to see a program's result. First display text and numbers; then combine values and control where lines begin.
By the end of this lesson, you can:
- Print text and numbers
- Read multiple lines of output
- Combine values in one print call
print() lesson progress0%
Course progress: 0% · 0 of 8 steps completed in this module
Learn · Text needs quotes; numbers do not
Text needs quotes; numbers do not
A string is text between matching quotes. A number can go inside print() without quotes. The displayed digits may look the same, but Python treats quoted and unquoted values differently later.
Pattern
print("some text")
print(10)Code
print("Ten")
print(10)Output
Ten 10
Why it works
- The first call displays text.
- The second displays a numeric value.
- Each call begins a separate output line.
Common mistake
Not this
print(Hello)Try this
print("Hello")Without quotes, Python searches for a variable named Hello.