Introduction to Python

by Mar 26, 2020Python

www.edyoda.com

In this tutorial we are going to learn Python programming language starting from basic up-to it’s the advanced level.

www.miltonmarketing.com

Python is an open-source project, supported by many individuals. It is a platform-independent ( used in Windows, Mac, Linux, Raspberry Pi, etc.), scripted language, with complete access to operating system APIs. It was developed by Guido van Rossum, in February 1991. This allows users to integrate applications seamlessly to create high-powered, highly-focused applications. The contents of this article are shown below:

Why do we need Python?

Python has been constantly improved by a community of users who have always strived hard to take it to the next level.

  • Simple Python is a simple and small language. Reading a program in python is almost reading in English. Therefore, an advantage of python that allows programmers to concentrate on the solution to the problem rather than the language itself.
  • Easy to learn Python program is clearly defined and easily readable. The structure of the program is very simple. The keywords and syntax are very easy to remember. This makes it easy for just anyone to pick up the language quickly.
  • Versatile Python supports the development of a wide range of applications ranging from simple text processing to WWW browsers to games.
  • Free & open-source Python is open-source software. So that anyone can read the source code, edit it, and even use the code to write new (free) programs.
  • High-level language Programmers don’t have to worry about the memory used by the program like any low-level language. They just concentrate on writing the solutions to the problem.
  • Object-Oriented Python supports object-oriented as well as a procedure-oriented programming approach. Object-oriented simply means that encapsulation of data and functionalities within objects. On the other hand, procedure-oriented techniques mean reusable pieces of programs.
  • Secure The Python language environment is secure from tampering. Additional security checks can be easily added to implement additional security features. Apart from that, modules can easily be distributed for the prevention of altering the source code.

Python IDE

Python IDE refers to the Integrated Development Environment which integrates several tools specifically designed for software development. This includes :

  • Builds, Execution, Debugging tools
  • Some form of source control
  • Designed to handle codes(like auto-completion, save and reload code files, run code from within the environment, auto code formatting, syntax highlighting.)

Python IDLE

Python IDLE intended to be a simple IDE for beginners, especially for educational purpose. It is packaged as an optional part of the Python packaging of many Linux distributors. IDLE has the following features:

  • coded in 100% pure Python, using the Tkinter GUI toolkit
  • cross-platform: works mostly the same on Windows, Unix, and MAC.
  • Python shell window with colourizing of code input, output, and error messages.
  • multi-window text editor with multiple undo, Python colourizing, smart indent, call tips, auto-completion, and other features
  • search within any window, replace within editor windows, and search through multiple files.
  • debugger with persistent breakpoints, stepping, and viewing of global and local namespaces
  • configuration, browsers, and other dialogues.
You can download Python IDLE just by click here

After download and install it you can just write “IDLE” in the search box in the taskbar of your system and can see the app. Your Python IDLE display will be like this :

The following are the most used IDEs for Python:


Jupyter

The Jupyter Notebook supports markdowns, allowing you to add HTML components from images to videos. Thanks to Jupyter, you can easily see and edit your code in order to create compelling presentations. For instance, you can use data visualization libraries like Matplotlib and Seaborn and show your graphs in the same document where your code is. Besides all of this, you can export your final work to PDF and HTML files, or you can just export it as a .py file. In addition, you can also create blogs and presentations from your notebooks.

You can download just by click here

PyCharm

PyCharm is an IDE for professional developers. It is created by JetBrains, a company known for creating great software development tools. There are two versions of PyCharm:

  • Community – free open-source version, lightweight, good for Python and scientific development.
  • Professional – paid version, full-featured IDE with support for Web development as well.

PyCharm provides all major features that a good IDE should provide: code completion, code inspections, error-highlighting and fixes, debugging, version control system and code refactoring. All these features come out of the box.

You can download PyCharm by click here

Eclipse + PyDev

If you’ve spent any amount of time in the open-source community, you’ve heard about Eclipse.  It has a rich marketplace of extensions which makes Eclipse useful for a wide range of development activities. One such extension is PyDev, which enables Python debugging, code completion, and an interactive Python console.

Installing PyDev into Eclipse is easy. From Eclipse, select Help, Eclipse Marketplace, then search for PyDev. Click Install and restart Eclipse if necessary.

You can download this just by click here

Anaconda

Anaconda® is a package manager, an environment manager, a Python/R data science distribution, and a collection of over 7,500+ open-source packages. Anaconda is free and easy to install, and it offers free community support.

You can download it from just click here

Spyder

Spyder is an open-source Python IDE that’s optimized for data science workflows. It comes included with the Anaconda package manager distribution, so depending on your setup you may already have it installed on your machine. What’s interesting about the Spyder is that its target audience is data scientists using Python. You’ll notice this throughout. For example, Spyder integrates well with common Python data science libraries like SciPy, NumPy, and Matplotlib.

You can download it by click here

Python Versions

Here are the versions of Python (old and new). Python 2 versions are being obsolete. The latest version which is used mostly everywhere is Python 3.8. In this tutorial, we will work on Python 3.7.4 version.

www.docs.python.org


Python Install

Many PCs and MAC have already installed Python in it. Check if the Python is already installed or not we can simply go to command prompt window (in short cmd.exe), then check it.

C:\Users\Your Name>python --version

If the version is not showing then you can simply click this link —https://www.python.org/ and then download Python for your Windows version and install, then again check it in the command prompt.

Python Syntax

Python syntax can be executed by writing directly in the Command Line                      

print("hello World")

You can see like this —

Or, also we can create a python file on the server using .py type file extension and run it in the command line.

C:\Users\Your Name>python myfile.py

It can seem like the above.

Python has a set of keywords that are reserved. It can’t be used further as names of variables. Here is the list of Python keywords.

andasassertbreakclass
continuedefdelelifexcept
Falsefinallyfarfromglobal
ifimportinislambda
Nonenonlocalnotorpass
raisereturnTruetrywhile
withyield

Python Comment

Comments are the non-executable statements in a program. Comments make the program easily readily and understandable by the programmer. Python uses a hash sign (#) to indicate a comment.

#This is a comment
print("hello World")

To make code more readable and understandable, Python uses multiple comments.

#This is a comment
print("Hello World") #To display hello
#The code ends here

A multi-lined comment uses triple quotes like (‘ ‘ ‘) or (” ” “)

def double(val):
      """function to double the val"""
      return 2*val

Python Indentation

White-space at the beginning of the line is called indentation. These indentations are very important in Python. The leading white-space including spaces (by default Python puts 4 spaces, it can be changed by programmers.). Tabs at the beginning of the logical line determine the indentation level of that logical line. Program to exhibit indentation errors:

age= 21
    print("You can vote")

An important thing to know is that we can only use 4 spaces under a condition(like any for statement)

If there another condition is introduced within the previous, for we should use 4 more spaces(i.e., 4+4=8 spaces) and so on.

for i in range(1,5):
    print('Table of '+str(i))
    for j in range(1,5):
        x=i*j;
        print(str(i)+'x'+str(j)+'='+str(x))

In the above code the j’s loop iterates within I’s loop. So, 4 spaces are used for the statements under I’s loop and 8 spaces for j’s loop.

The following is the output of the above code.

We should not leave space in Python. It will show an error like the below.

if(10>2)
   print("10 is greater than 2")
       print("10 is greater than 2")

If we don’t use same no. of spaces in the same block of codes Python will give an error.

Creating a multiplication Skill in Alexa using python

Written By Itika Sarkar

Hey, this is Itika Sarkar. I'm currently pursuing BTech degree in Electronics & Communication Engineering(2nd year). Writing technical articles, tutorial and innovative projects on modern industry-related technologies are my hobbies.

RELATED POSTS

Python Regular Expression

Python Regular Expression

Python is a general-purpose high-level programming language. Python is mainly used as a support language to software developers. It helps in building control and management and also in testing. The syntax python uses is very simple and similar to the English language....

Introduction to MicroPython and ESP8266

Introduction to MicroPython and ESP8266

For ages, C and C++ have ruled over the embedded system industry. Fast prototyping is an important aspect of the industry today. In fact MicroPython is the best suited for fast prototyping. Students and engineers are becoming very familiar with the Python programming...

Five Best Python Projects for Beginners

Five Best Python Projects for Beginners

Learning and practicing of any programming language can be monotonous. Also, only learning can not be the perfect gain of knowledge if we don't put it into some implementation. Likewise, Python programming language can be interesting but until we don't use it in some...

How to convert .py into .pyc? Compilation of Python Code

How to convert .py into .pyc? Compilation of Python Code

In this article we will see what is a pyc file ,how is it formed,how to convert and compile a pyc file. When we run a code in python it actually goes through a couple of steps before our program reaches the virtual machine It is compiled to bytecode.Then it is...

How to create and install a Python Package?

How to create and install a Python Package?

Requirements Check the tools pip --version pip install wheel What is Python Package Index? What is Distutils? Creating a Package Directory Structure some_root_dir/ |-- README |-- setup.py |-- an_example_pypi_project | |-- __init__.py | |-- useful_1.py | |--...

Docker for beginners tutorial:

Docker for beginners tutorial:

What is Docker? Docker, in simple words is a tool that allows developers who build applications, to package them with all their dependencies into a ‘container’ which can easily be shipped to run on the host operating . Containers do not have high overhead and allow...

Object-Oriented Programming in Python

Object-Oriented Programming in Python

Python Classes and Methods Python is an object-oriented programming language. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made....

Python Flask Tutorial

Python Flask Tutorial

Flask is a web framework that provides libraries to build lightweight web applications in python. It is developed by Armin Ronacher who leads an international group of Python enthusiasts (POCCO). Contents What is Flask? Flask Environment Setup First Flask...

Python Numbers

Python Numbers

In this article you will learn about types of numbers in python and their mathematical operations. So these are the contents of this article : Introduction Decimal Need of DecimalFractionsMathematics Introduction Python supports integer, floating-point number and...

Python File Handling

Python File Handling

In this article, we will discuss all about file handling in Python. Let us have a quick look at the contents shown below: IntroductionFile openSyntaxRead filesParts of file to readRead linesloopChoose filesWrite filesAppendSplitting wordsCreate a new fileSeek...

Python Lambda

Python Lambda

In this article, we will discuss on Python lambda. Let us have a quick look on the following contents shown below: IntroductionAdd two numbers using LambdaSum of 10 natural numbersMultiplicationSmaller of two numbers Introduction Lambda functions are the anonymous...

Python Functions

Python Functions

In this article, we will tell about Python functions. We should also know about function defining function calling and variable arguments. Let's have a quick look on the below contents : IntroductionFunction CreationDefinitionDeclarationCallArgumentsRequired...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....