"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Python print() method

Python print() method

Published on 2024-08-07
Browse:994

Python print() method

Today we are going to see python print statement usage.
Print is used to print the output in the console.

Printing a simple string

print("Hello, World!") # Output: Hello, World!

Printing numbers

print(123) # Output: 123
print(3.14) # Output: 3.14

Printing multiple values

print("The answer is", 42) # Output: The answer is 42

Using formatted strings (f-strings)

name = "Alice"
age = 30
print(f"My name is {name} and I am {age} years old.") # Output: My name is Alice and I am 30 years old.

Printing with different separators and end characters

print("Python", "is", "fun", sep="-") # Output: Python-is-fun
print("This is the first line.", end=" ") # Output: This is the first line. This is the second line.
print("This is the second line.")

Release Statement This article is reproduced at: https://dev.to/kumar_tech_6d30f8ab1ef22c/python-print-method-2058?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3