For more information about Python and other tutorial in this series, go to static page of this tutorial here: Python as A Hobby! [ ].
As mention earlier, you can get Python from python.org. Just go to python.org and download python installation file to you computer. Python has editions for different OS. Python for Linux, MacOS and Windows. Just get the one appropriate to you. In Windows and MacOS, thing goes easily. Just double click in to your downloaded file and Next, Next, Next, ...
For Windows users, after download file .msi or .exe from Python.org and install it as usually, you can run Python from DOS or from Python IDLE (IDLE is the default IDE for Python) .
In Linux, Ubuntu for example, you usually got Python installed before. Just go to terminal and type:
python
Successful screen look
like this:
It is too easy for you.?
Look at the picture above, we can see that this machine are using Python 2.7.1 (not Python 3.0) for further information we could use command help, credits, ...
It is done. You have just installed Python.
After successfully install Python, from terminal we can do some thing with Python via some exaple.
Example 1: Using command print
>>> print "Helloooo World from Microtrix.blogspot.com!"
Press enter and you get:
Helloooo World from Microtrix.blogspot.com!
>>>
Example 2: Using variables
>>> a = 10
>>> print a
You will get:
>>> a = 10
>>> print a
10
>>>
Example 3: Using input
>>> name = raw_input("Please enter you name: ")
Please enter you name: microtrix.blogspot.com
>>> print "Hello dude: ", name
Hit enter and you get:
>>> name = raw_input("Please enter you name: ")
Please enter you name: microtrix.blogspot.com
>>> print "Hello dude: ", name
Hello dude: microtrix.blogspot.com
Exaple 4: Doing math
>>> a = raw_input("please enter a number. I will double it: ")
please enter a number. I will double it: 12345
>>> print "Double it gives: ", (int(a)*2)
Hit enter and you get:
>>> print "Double it gives: ", (int(a)*2)
Double it gives: 24690
>>>
Example 5: Comments
>>> #this line is comment, so dont worry....xyz
... print "comment ex" #comment again
comment ex
>>>
No comments:
Post a Comment