Setting up Python
Before moving any further let's install and setup Python in our system.
Python comes in two flavours, 2.x and 3.x. The original 2.x series was re-written and 3.x was born. Python 3 was the first release which not backward compatible and forced a lot of syntax changes and refactoring on the existing users, so most of the features in 3.x was ported back to 2.x series and they're almost indistinguishable except for some syntax differences. 2.x is still more popular than 3.x series, however to stay ahead of the times, we'll go for learning Python 3.
As of now the latest version of Python 3 is 3.4. To install Python 3.4, go to https://www.python.org/downloads/
Installation instructions are also available in the same page and it is pretty straightforward. Python comes preinstalled with most operating systems but it is usually 2.7, So we'll go ahead and install Python 3.4.
Go to your terminal/Command prompt and type: python and press enter to see if Python is installed and is in path. Since we're installing Python 3, we have to use python3 as the command in the terminal.
$ python3
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Executing python3 will launch the python interpreter and you can interactively type python commands and get output printed on the console.
Unlike java or C, the Python interpreter doesn't require you to create a file, compile and execute it. You can straight away start typing and get your results in the command window.
The interpreter interface is just for debugging and some initial or standalone function or module which you may want to incorporate into a codebase or a program. The interpreter is what runs the Python script so it is needed. However we will write the code in *.py files and execute them using the interpreter command, which is python3
References:
- https://www.youtube.com/watch?v=oVp1vrfL_w4
- https://wiki.python.org/moin/Python2orPython3
- https://docs.python.org/3/whatsnew/3.0.html
- https://www.python.org/downloads/
Previous chapter: Introduction Next Chapter: Hello World!
No comments:
Post a Comment