Print in Python

HOW TO 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.

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


Posted

in

Tags:

Comments

Leave a Reply