800+ Companies Hiring Full Stack Developer- Register Now

Basics of Python | History of Python| When Was Python Created.

Register Yourself to get hired soon:- Register Now

Python is an Object-oriented, high-level, dynamic, and multipurpose programming language.

Python supports multiple programming patterns, including object-oriented programming, imperative and functional programming, or procedural styles.

It is an interpreted language (CPython). We don’t need to use data types to describe variables, because it is dynamically typed. So we can write a=10 to declare an integer value in a variable

Python makes the development and debugging fast because there is no complication step Included in the python development and edit-test-debug cycle is very fast.

It was created by Guido Van Rossum in the Netherlands during 1989-1991.

Accenture Mass Hiring For Freshers:- Apply Now

Why Named Python:

Guido Van Rossum was the fas of “Monty Python’s Flying Circus” It was a famous TV show in Netherland, so that named Python.

It is Open-sourced From the beginning

Versions of Python:

NameDate
Python 1.0Jan 1994
Python 2.0Oct 16, 2000
Python 2.7.15May 01, 2018
Python 3.0Dec 03, 2008
Python 3.7Jun 27 , 2018

Scop of Python:

  • Scope based application (IPython)
  • GUI Based Application
  • Audio /Video based application (TimePlayer, CPlay)
  • 3D, CAD Application (Fandango)
  • Enterprice or organization Applications (openERP, Trython, Picalo)
  • Web Applications (PythonWikiEngins, Pocoo, PythonBlog Software)
  • Gaming Applications

Feetures OF Python:-

There are a lot of features Provided by the Python Programming language:

  • Easy to use.
  • Expressive language.
  • Easy to learn.
  • Interpreted Language.
    • Cross-Platform language.
    • Free and Open Source.
    • Object-Oriented language.
    • Large Standerd Library.
    • GUI Programming
    • Integreted Language.

Modules of Python:

In Python, There are many Inbuilt modules Present for developing different applications:-

  • If we want to create GUI application we can use following modules: – Tkinter, WxPython, JPython (For GUI Programming).
  • If we want to create Socket or Nerwork Application we can use following :- Socket module
  • For Audio/ Video Application we can use: WxPython
  • For Game Programming we can use:- Pygame.
  • If we want to work on data we can use some important following module:- Numpy, SciPy, Pandas, Matplotlib , Seaborn.
  • For Machine learning :- Scikit Learn , TensorFlow, Pytorch
  • For Example:- Email, Driverless car, Google, FB.

Web Frameworks of Python:

  • Django
  • Flask
  • CherryPy
  • TurboGears
  • Web2Py
  • Bottle
  • Falcon
  • CubicWeb
  • QuiXote
  • Pyramid
  • FastAPI
  • Tornado

All the above Frameworks are used only for Web Development.

IDE Of Python:-

  • IDLE
  • Pycharm
  • Anaconda
  • Spyder
  • Pydev
  • Wing IDE
    Eric
  • PyScripter
  • Sublime Text
  • Visual Studio Code

Python Code Exicution:-

Python Traditional runtime execution model first translates our source code into byte code, which is run by the Python virtual machine. Our code is automatically compiled, but it is interpreted

  • Step 1: The python compiler reads and undarstand a python source code or instruction. Then it verifies that the instruction is in structure and well-formatted, i.e. it checks the syntax of each line. And then If it encounters an error, it immediately halts the translation and shows an error message.
  • Step 2: If there is no error, i.e. if the python instruction or source code is well-formatted then the compiler translates it into its equivalent form in an intermediate language called “Byte code”.
  • Step 3: Byte code is then sent to the Python Virtual Machine(PVM) which is the python interpreter. PVM converts the python byte code into machine-executable code. If an error occurs during this interpretation then the conversion is halted with an error message.

Source code Extension is .py. Byte code Extention is. Pyc (compiled Python code)

How to Create a simple program in Python:-

Following 3 ways are there to create a simple program in Python

  • Interactive Mode.
  • Script Mode.
  • IDLE Mode.

Interactive mode:-

To create a Python program in Interactive mode. first of all, we will open our terminal or Command Prompt. And then Type Python or Python3 Your interactive mode will open. Now we are going to write a simple welcome program using some variable and print functions.

Python Code

Script Mode:-

Open any text editor like notepad, sublime text.

a=10
b=10.5
c=a+b
print("add=",c)

Save file:- CTRL + S –> All file Type –>Save with .py extention

Output:- 20.5

IDLE mode:-

Run –> IDLE –> Software –> CTRL+N

a=10
b=10.5
c=a+b
print("add=",c)

CTRL+S to save the file and then press f5 to run that file.

How to make comment in python:-

For single-line comments use ‘#’

#write anything like a comment here.

For multiple line use tripple quotes

'''Use tripple quotes to make 
multiple lines like comment'''

Some Important and basic program in Python

Multiple Assignemt:

a,b,c=10,20,30
print(a)
print(b)
print(c)

#Output:-
10
20
30

a=b=c=10
print(a)
print(b)
print(c)

#Output:-
10
10
10

Swapping without using third variable:-

a=10
b=20
print("before swapping" a,b)
a,b= b,a
print("After Swapping", a,b)

#Output:- 
#Before Swapping 10,20
#after Swapping 20,10

in the above code, we store two constant values in two different variables and we want to swap them with each other. if we want to swap them in other languages like c, c++, java then we will need the third variable to swap them. but in python, we can do it without a third variable. we can initialize multiple variables in one line using python.

Some Important point in Python version 2.7.13

  • Brackets are not compulsory
  • there is no need of type casting when we use input() funtion.
  • If we use bracket at print statement the output will not be correct.
  • if we use row-input then we have to use typecasting.

Assignment:-

Now you have enough knowledge to create a simple program in python let’s have a small assignment that you have to solve

  • Enter Any two numbers and create swapping program using third variable?
  • Enter any length and width and find out area of ractangle ?
  • Enter any five different subject marks and find out aggregate marks and average? each subject out of 100 marks?
  • Enter any basic salary of an employee and find out DA, HRA,and TA and net salary. DA=10% of basic salary, HRA=20% of basic salary, TA = 5 % of basic salary, Net Salary=?
  • Enter any number of days and find out how many years, how many months and how many remaining days ?

Leave a Comment