Python

 

 

 

 

Python - Print

 

print() is the most important function in Python (actually the most important function in any language). There is nothing to explain specifically. Just follow through following examples.

 

NOTE 1 : All the examples in this page are written in Python 3.x. It may not work if you use Pyton 2.x

NOTE 2 : All the examples in this page are assumed to be written/run on Windows 7 unless specifically mentioned. You MAY (or may not) need to modify the syntax a little bit if you are running on other operating system.

  • Basic Syntax
  • Examples

 

Basic Syntax :

 

 

Examples :

 

    < Example 1 >

     

    print("Hello World")

     

    Result :--------------------------

    Hello World

     

     

    < Example 2 >

     

    print('Hello World')

     

    Result :--------------------------

    Hello World

     

     

    < Example 3 >

     

    score = 75

    print("Your score is ",score)

     

    Result :--------------------------

    Your score is  75

     

     

    < Example 4 >

     

    score = 75

    grade = "C"

     

    print("Your score is ",score, " And ", "Your Grade is ",grade)

     

    Result :--------------------------

    Your score is  75  And  Your Grade is  C

     

     

    < Example 5 >

     

    score = 75

    grade = "C"

     

    print("Your score is ",score, "\nYour Grade is ",grade)

     

    Result :--------------------------

     

    Your score is  75

    Your Grade is  C

     

     

    < Example 6 >

     

    print("===Print without New Line at the end ===")

    for i in range(5) :

        print(i, " ")

     

    print("===Print without New Line at the end ===")

    for i in range(5) :

        print(i, " ", end=' ')

     

     

    Result :--------------------------

     

    ===Print without New Line at the end ===

    0  

    1  

    2  

    3  

    4  

    ===Print without New Line at the end ===

    0  1  2  3  4  

     

     

    < Example 7 >