Python – What is a Program ?

Before beginning with learning Python programming we need to understand what is a Program (more specifically Computer Program).

A Program is a sequence of instructions that specifies how to perform a computation. Computation can be anything like – taking input from user and perform mathematical operations, solving for roots of an equation or playing a audio/video file.

For different programming languages, the specifics to do these tasks can be different. But few basic instructions(below) appear in just about every language.

INPUT : take input in the program (can be user input from keyboard, a file, some data from network or other device)

MATH : performing basic mathematics operations (addition/subtraction)

CONDITIONAL EXECUTION : check for certain conditions and taking appropriate action

REPETITION : perform some action repetitively (that’s what computers are known for…)

OUTPUT : displaying the final output of program on screen, saving in a file or sending over a network/ other device

That’s the basic outline of every program you will ever gonna write.

So in a nutshell PROGRAMMING is the process of breaking a large and complex task into smaller and smaller sub-tasks until sub-tasks are simple enough to be solved with the basic instructions given above.

 

Python for beginners.

print "Hello Shubhankar"

Introduction to Python

Python is a widely used general-purpose, high level programming language. It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code.

There are two major Python versions- Python 2 and Python 3. Both are quite different.

For this tutorial we will follow Python 3 and Linux(Ubuntu) will be used in our examples but the possible installation and errors for Windows and MacOS will also be provided where necessary but the main focus will be on Linux as it’s important to have a basics of linux commands.

If you don’t own a Linux machine, https://www.pythonanywhere.com is for you where you can create your account for free and have a Bash Console.

 

Beginning with Python Programming

Before beginning to Python, we hope that your python setup is complete or your can go to

Configure Python in Eclipse with Pydev – Download and Install

In these tutorials, we will be learning Python, so that we can use it to make great IoT projects, instead of using python shell, I will recommend you guys to configure an IDE so that your programming is much faster and efficient.

Here we will learn how to Download-Install-Configure PYTHON with eclipse and start using the environment for programming.

Installing Python

python insatallation

Firstly, we will download and install Python on our Machine aka PC –

https://www.python.org/downloads/   – Download the latest version of Python (don’t download the legacy[older] version) and start with the normal installation process.

During Installation check ‘Next’ a bunch of times but do remember to tick the checkbox – add as an environment variable. If you forget to tick that box check out This Article 

Now that we are done with the installation, we will confirm if python is correctly installed or not by typing ‘python‘ on the terminal

C:\Users\Samarth Gupta>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

This confirms that python is successfully installed on your machine.

Installing Eclipse

eclipse inatallation

Now we will download the Eclipse as out IDE – https://www.eclipse.org/downloads/

As of writing this post Eclipse Oxygen was the latest version. During installation configure it as a JAVA environment.

Installing and Configuring Pydev

Ohh yes, we just clicked a few buttons and now we have both Python and Eclipse installed, now its time to unite them with a plugin called ‘Pydev’

Open Eclipse -> Help -> Eclipse Marketplace

pydev-installation

Now search for Pydev and click install


After installation, we will create a new Python Project with the help of pydev

Follow the below Steps

  1. Click – File -> New -> Other (choose pydev project)choose pydev project
  2. Now Configure the project as below and click Finishpyhton project specs
  3. That was easy – our project is ready, now we will create our first python file (right-click the project -> New -> File and give it some name with extension ‘.py’).
  4. Edit the python file as below and click ‘Run’ (just hit next to whatever alert comes in your way)
    print('batman is here')
  5. Now you can see in Console the output is printedpython-program

From now on we will be writing all our code in these .py files and output will be printed in the console window.

That was all with the configuration need for our python projects. Now just dive into the programming with python in our coming tutorials.