How to print integer values in Python?

Estimated read time 1 min read

Printing integer values in Python is straightforward. You can use the print() function to display integer values. Here’s an example:

x = 10
y = 20

print(x)  # Prints the value of x
print(y)  # Prints the value of y

In this example, the print() function is used to display the values of the variables x and y. The output will be:

10
20

By default, the print() function adds a newline character at the end of each printed value, so each integer will be displayed on a separate line. If you want to print multiple integers on the same line, you can use the end parameter of the print() function and set it to an empty string "". Here’s an example:

x = 10
y = 20

print(x, end=" ")
print(y)

In this case, the output will be:

10 20

The end=" " sets the end parameter of the print() function to a space character, which ensures that the next printed value is separated by a space instead of a newline.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply