Source: Online social media and website

Download and installing python



You can download Python for Windows, OS X, and Ubuntu for free from http://python.org/downloads/. If you download the latest version from the website download page.

You’ll find Python installers for 64-bit and 32-bit computers for each operating system on the download page, so first figure out which installer you need. If you bought your computer in 2007 or later, it is most likely a 64-bit system. Otherwise, you have a 32-bit version, but here’s how to find out for sure:

  • On Windows, select StartControl PanelSystem and check whether System Type says 64-bit or 32-bit.

On Windows, download the Python installer (the filename will end with .msi) and double-click it. Follow the instructions the installer displays on the screen to install Python, as listed here:

  1. Select Install for All Users and then click Next.
  2. Install to the C:\Python34 folder by clicking Next.
  3. Click Next again to skip the Customize Python section.

Starting IDLE


While the Python interpreter is the software that runs your Python programs, the interactive development environment (IDLE) software is where you’ll enter your programs, much like a word processor. Let’s start IDLE now.

  • On Windows 7 or newer, click the Start icon in the lower-left corner of your screen, enter IDLE in the search box, and select IDLE (Python GUI).
  • On Windows XP, click the Start button and then select Programs Python 3.4IDLE (Python GUI).

Programming at Python

Entering Expressions into the Interactive Shell

A window with the >>> prompt should appear; that’s the interactive shell. Enter 3 + 3 at the prompt to have Python do some simple math. 

 

String Concatenation and Replication

 

The meaning of an operator may change based on the data types of the values next to it. For example, + is the addition operator when it operates on two integers or floating-point values. However, when + is used on two string values, it joins the strings as the string concatenation operator. Enter the following into the interactive shell:
 
The expression evaluates down to a single, new string value that combines the text of the two strings. However, if you try to use the + operator on a string and an integer value, Python will not know how to handle this, and it will display an error message.


The error message can’t convert 'int' object to str implicitly means that Python thought you were trying to concatenate an integer to the string 'Mango'.

Installing Third-Party Modules

Beyond the standard library of modules packaged with Python, other developers have written their own modules to extend Python’s capabilities even further. The primary way to install third-party modules is to use Python’s pip tool. This tool securely downloads and installs Python modules onto your computer from https://pypi.python.org/, the website of the Python Software Foundation. PyPI, or the Python Package Index, is a sort of free app store for Python modules.

The pip Tool

The executable file for the pip tool is called pip on Windows and pip3 on OS X and Linux. On Windows, you can find pip at C:\Python34\Scripts\pip3.exe.


Module creation

User defined module

A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended. Within a module, the module’s name (as a string) is available as the value of the global variable __name__. For instance, use your favorite text editor to create a file called fibo.py in the current directory (C:\Users\****\AppData\Local\Programs\Python\Python36-32\Lib) with the following contents: 




def fib2(n):   # return Fibonacci series up to n

    result = []
    a, b = 0, 1
    while b < n:
        result.append(b)
        a, b = b, a+b
    return result
 

Now enter the Python interpreter and import this module with the following command:



Standard module

Access windows DOS commands

You can execute the Disk Operation System (DOS) commands in python IDLE.