Python Setup – Windows, MAC and Linux, Python Basics | First Python Script

This post explains about Python Setup on different OS like Windows, MAC & Linux. We will also learn about Python basics like commenting, PIP, PY charm and first Python script. Let us start step by step.

Python Setup on your machine

Python Setup on Windows

  1. Go to download python page on official site
    https://www.python.org/downloads/
  2. Click on Download python 3.6.4 (Version may change) and complete the download
  3. Double click on downloaded file. It will launch the python installer. Follow the instructions and you will see “The installation was successful” message when Python is successfully installed.

Python Setup on Mac OS

  1. Go to download python page on official site
    https://www.python.org/downloads/
  2. Click on Mac OS X below section “Looking for Python with a different OS? Python for Windows”
  3. Click on Mac OS X 64-bit/32-bit installer (Version may change) and complete the download
  4. Double click on downloaded file. It will launch the python installer. Follow the instructions and you will see “The installation was successful” message when Python is successfully installed.

Python Setup on Ubuntu

Python 3 is installed by default on modern versions of Ubuntu, so you should already have it installed. On command line run:

python3 -V

You should see current installed version of Python on your machine.

Introduction to PyCharm

By now you have successfully installed Python on your machine by following steps in previous section.

Now you need a good text editor to make and run your scripts. Windows installer of python comes with a default text editor called “IDLE”. You can surely use it but I personally prefer a text editor called PyCharm.

PyCharm can be used from making a small script to large professional application.

Go ahead, download and install PyCharm. We will soon use it to make our first script.

Basics of PIP command line

As a popular open source development project, Python has an active supporting community of contributors and users that also make their software available for other Python developers to use under open source license terms.

This allows Python users to share and collaborate effectively, benefiting from the solutions others have already created to common problems, as well as potentially contributing their own solutions to the common pool.

PIP is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.

Open a command prompt or shell prompt depending on the OS you are using and type

pip -h

If python is installed correctly on your machine, then it should list all available commands for pip.

Let’s say you want to install Requests library to make http calls. Open command line and type:

pip install Requests

Successful completion of this command will install request library in your PC. You can now import and use it in your scripts.

Hands On

Culture of indentation

Python functions have no explicit begin or end, and no curly braces to mark where the function code starts and stops.

name=input("Enter the academy name: ")

if name == 'rcvacademy':

print("Yes please")

else:

print("We are unable to find this academy")

We will discuss the syntax details later, here I just want to show you that unlike other languages python does not use brackets to mark the begin and end of a statement.

It uses “:” and indentation to show that we are in a code block.

These indentations will be automatically added by your python supported text editors. Advantage of this approach is, you will always get a well-structured code in the end.

How to comment in Python

It is a good practice to put comment in our program to make it more understandable.

Comments in the program are the statements which will not be executed. These are the pointers for the developer, that what a certain piece of code is supposed to do.

Python provides two types of commenting methods:

Single line comment in Python using hash (#)

print (“You are here”) #This is a comment

Multiline comment in Python

"""

This is

a

multiline comment

"""

Say hello to world (Make your first script)

OK let’s start with our first script.

Open PyCharm and click on File->New -> Then select python file -> Name your file like first_prog.py.

“py” extension indicates that it’s a python script.

Now write code as shown below and save it.

print ("Hello World")

Run this program by pressing the Run button. You should see Hello World on output prompt.

That’s it, this is all about Python basics and first Python program

Python Language Introduction – Importance and its Application

Introduction to Python Language

Python language is a widely used general-purpose, high-level programming language. It was developed by  Guido van Rossum at CWI in the Netherlands.

Python 1.0 was released in 1994. Since then language have seen many changes and improvement so far. Python is an open source language. It is driven by a great community of developers and testers from all over the worlds.

Here are few pointers about “Why you should learn python language”.

  • One of the major advantages of python is its syntax and readability. It has an intuitive syntax which makes user to focus on logic rather than tiny language details.
  • Python language supports all major Operating systems available, like Windows, MAC and Linux.
  • Python efficiently handles lower level operations like garbage collection and memory management by itself. You don’t have to worry about these things.
  • Python has a vast collection of standard libraries which speeds up the development process.
  • Python can seamlessly collaborate with other important languages Like C, Java. For example- Jython is a flavour of python language which can import a JAVA classes and use them.

Importance of Python Language in current technical space

Python is showing an ever-growing demand in many technical areas. Some important areas are as follows:

Web Development

Frameworks such as Django  and Flask made python very popular in the area of web development. Their ease of use and extensibility has made them a favourite among newbie’s as well as experienced professionals.

Scientific and Numeric

Python is a first choice for scientific calculations and data crunching. It has some superb libraries to perform these kinds of tasks.

  • SciPy is a collection of packages for mathematics, science, and engineering.
  • Pandas is a data analysis and modelling library.

Automation

Python is being used heavily in automation domain. Major automation frameworks like Selenium and Appium supports python. Python have some famous native automation tools also like robot

Education

Python’s elegant and simple syntax has made it very popular in the academic sector. Recent trend has shown that Python past Java as first choice of programming language.

Universities like MIT now teach programming in Python language.

https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/