Python Tutorial

Here you can learn about the basics of Python for free.

Monday, June 3, 2019

Print() function & statement







Understanding  print( ) :-
To print or display output ,python provide print( ) function.You can use print() as
print(<objects to be printed >...)

      e g.,,when you wrote
      print("My name is xyz")

it will print 
      My name is xyz
Double and single quotes:
↳print('Hello world')
↳print("Hello world")

Note: Both these strings are valid in python.you can enclose your strings in either double or in single quotes, but just ensure that opening and closing quotation mark should be of same type.

'Hey there"↶ This is invalid



Output through print statement:-
let's take a few examples→
print("Hello")                  #a string
print(17.5)                       # a number
print(3.14*3)                    #some calculation occur and print the final result


Features of print statement :-
↳print("My","name","is","Amit.",sep='...')
will print
        My...name...is...Amit.
let's take a look in python interpreter:-


end=' ' argument:-
let's take a few examples→
↳print("My name is Amit",end='  ')
↳print("I am 16 years old.")

will print output as:
          My name is Amit.  I am 16 years old.
In script mode:-


 Output:----