Introduction to Python

Python is a general purpose , interpreted , interactive and object oriented programming language.

It supports both functional and structured approach as well as object oriented programming.

It is easy to learn, use and understand.

IDE available: IDLE,PYCHARM,SPYDER,PYDEV etc

LETS START LEARNING PYTHON

Steps for Installing an Python IDE

Select any python IDE of your choice and install the same.

Here we will see about installing PyCharm

  1. Download the PyCharm package from https://www.jetbrains.com/pycharm/

2)   Run the downloaded package and open the application as below 

3)  Choose the Create New Project and give a suitable name for the project of your choice.

4)  Choose Base Interpreter as Python3.8 (preferable version greater than 3) 

5)  In the left pane , you will be able to view the created project

6)  Let’s start with a basic program to better understand the python structure.

7) Go to File -> New and create a python file and give a suitable name.

8)  Python file will be created in .py format and will be placed under the project created.

9)  Lets write a simple code in python to do addition of two numbers based on users input.

10) To run the program , Go to Run -> Run the .py file 

Let’s understand the program :

In this program we are defining a Class called Sample which has two methods __getinput() and sPrint() methods

__getinput() is a private method and it is accessible only within the class.Private methods are declared by double underscore before the name __

sPrint() is a public method and can be accessed in all the classes of the package.

s1 is the object created for the class Sample

s1.sPrint() statement calls the methodPrint() 

sPrint() method in turn calls the private method __getinput()  to get the inputs from the user.

__getinput() returns the user inputs and sPrint() performs the addition of two numbers and prints the result.

1 thought on “Introduction to Python”

Comments are closed.