HOW TO PRINT IN PYTHON

Print in Python

•print function,which writes to standard out. Standard out is where the computer writes its output.

•Strings or characters are enclosed in inverted commas.

Example of Print

print(“hello world”)

•Output of above statement.

hello world

•To print out multiple items, you can provide them separated by commas. You can put strings and numbers in a print function.

print(“my”,”program no.”,1)

Output of the above statement, Python inserted a space between them.

my program no. 1

Below statement will output the value you assigned to your variables(variable1 and A)

variable1=10

A=5

print(variable1, A)

Output of the above statement

10 5

To output multiple string variables we can use + operator:

B=”Hello”

C=”World”

print(B+C)

Output of the above statement

HelloWorld

In case of integer or float variables + operator will give sum of values stored in variables, as shown below:

B=5

C=10

print(B+C)

Output of the above statement

15


Leave a Reply

Your email address will not be published. Required fields are marked *