How to print in Python?

To print information in Python, you can use the print() function, which is used to display text or variable values.

Here are two examples:

  1. Print text.
print("Hello, World!")

Output:

Hello, World!
  1. Print the value of the variable:
name = "John"
print("My name is", name)

Output result:

My name is John

In the print() function, multiple values can be printed separated by a space. If you want to print variables of different types, you can use string formatting or convert them to strings before printing.

For example, printing both integers and floating-point numbers:

age = 25
weight = 68.5
print("I am", age, "years old and my weight is", weight, "kilograms.")

Output result:

I am 25 years old and my weight is 68.5 kilograms.
bannerAds