In Python, the print function is used to output text to the console or terminal. Here is an example of how to use the print function:
print("Hello, World!")
This will output the string "Hello, World!" to the console.
You can also use the print function to print the value of variables. For example:
name = "John"
age = 30
print("My name is", name, "and I am", age, "years old.")
This will output the string "My name is John and I am 30 years old." to the console.
You can also use the print function to print multiple things on the same line, separated by commas. For example:
print("Hello,", end = ' ')
print("World!")
This will output the string "Hello, World!" to the console, with a space between the two words.
You can also use the print function to print the output of a function or expression. For example:
def greet(name):
return "Hello, " + name
print(greet("John"))
This will output the string "Hello, John" to the console.