Monday 30 June 2014

Hello everyone!
Today I am going to introduce you all to a new and simple but effective function in Python i.e. a print( ) function.
The syntax for print() function is:

                            print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Let us try to understand it with the help of some examples on it.

1) print("Hello Python!")
>>> Hello Python!    

2)print(2+3)
>>>5        

3)a="my name "
   b="is Python"
   print(a+b)
>>>my nameis Python        #concetanation of two strings


Well in the first example we get to see that a print() function outputs whatever is present inside the parentheses. Here it outputs the string Hello Python!.
In the second example it is observed that here the print function outputs the sum of two numbers inside the parentheses. So this is something new about an o/p function like print() that we have encountered. All I  am trying to say is that taking reference of  a programming language like C and comparing both this seems to be a new and a very flexible task that a print() function is availing us with.
Ok  now lets see our third example wherein I have tried to express the beauty of print() function with the concept of concetanation of strings.

In my first blog on Introduction to Python I had mentioned that Python reduces the coding lines and through all of the above examples I have tried to show how clean Python's syntax is without adding the extra stuff that other languages add.

Thats all for today.
Please do try out and enjoy.
Happy  Coding.

1 comment:

  1. nice to learn about a language which i hav not heard before....bt why r u interested in programming now???

    ReplyDelete