Learn Python - 5 [print, printing]

in #python6 years ago

Photo 25.03.2018 7 13 41 PM.jpg
We already have seen print in previous posts. Now I want to focus on printing functionality. If you are a beginner it's a way to know your program really does what you want.

print() is a function and print whatever you pass to this function as a parameter. You can pass multiple parameters to the print() function.

>>> print(45)
45
>>> print('Hello Jamie')
Hello 
>>> print(1, True, 'Steem')
1 True Steem

As you see multiple parameters can be any type.
Now lets print variables values with print():

 >>> name = 'Joe'
 >>> print('Hello my name is', name)
 Hello my name is Joe
 >>> age = 29
 >>> print(name, 'is', age, 'old')
 Joe is 29 old

We can also concatenate strings with + while printing them:

>>> print('a' + 'b' + 'c' + 'd')
abcd

But for numbers it's different, it adds two numbers:

>>> print(4 + 5)
9

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 60947.53
ETH 2913.40
USDT 1.00
SBD 3.56