Showing posts with label Hello world. Show all posts
Showing posts with label Hello world. Show all posts

Thursday, June 25, 2015

Hello World with Python

Creating programs to print 'hello world' is a general concept, so I will start with that. Unlike any language where you have to call library to print the statement, Python has nothing Luke that.
So, for 'hello world' program -
If you are in Linux -
1. Open terminal and type Python.
         $python
2. Then just write print "hello world"
        >>print "hello world "
3. It will show the output "hello world"
For windows it is even more simpler,
Open the Python idle and type the above said statement. The out put will be the same.
But we need something more than "hello world" !
Open the terminal and write Python again. Write:  >>5+4
>>9
You can multiply,divide and do all the basic operations on the Python console.
You can also have variables.
>>a=5
>>b=4
>>c=a+b
>>9
You can see the output of c. The program is simply assign values to a and b variables and their addition in variable c. Python is smart enough to guess the  types of variables by itself.

Feautured Post

Python Trivia Post: enumerate()

Python has a very useful inbuilt function, which is called enumerate(). This is needed whenever you need the numbering of a certain element...