Introduction to Python
Prepared by:
Dr.M.N.Kavitha
Python
• Python is an interpreted, open source,
general purpose high-level programming
language having huge community support
and vast applications.
• Pythonwas developed by Guido Van
Rossum in the year 1991
Why is it named “Python”?
• Rossum was a big fan of the
famous BBC comedy series,
Monty Python’s Flying
Circus.
Features of Python
• Simple • Portable • Secure
• Easy to learn • Dynamic • Multithreaded
• Extensive libraries • Extensible • Easy maintenance
• Free and open • Enbeddable • Garbage collection
source • Object-oriented
• High-level language • Versatile
• Interpreted
Applications
• GUI based desktop applications
• Image processing applications
• Web development
• Graphic design applications
• Game development
• Network Programming
• Prototyping
• Artificial Intelligence and Machine learning applications
and so on….
Installing Python
• Go to the official website
www.python.org/downloads
• Download the latest python version for
Windows
• Run the downloaded file
• Follow the instructions and install it
Installing Anaconda
• Go to the website
www.anaconda.com/download
• Download the Windows version
C Vs Python
Example 1: Program to Print Welcome
C Code Python
Code
#include <stdio.h> print(“Welcome”)
int main()
{
printf(“Welcome"); Output:
return 0;
“Welcome”
}
C Vs Python
Example 2: Program to Print Sum
C Code
#include <stdio.h> Python
int main() Code
a=10
{
b=5
int a=10, b=5, sum;
sum = a+b; Sum=a+b
printf(“Sum= print(“Sum=“,
%d”,sum"); Sum)
return 0;
}
Variables
Variables are containers to hold any value
• Python is dynamically typed, i.e it takes the data type of the
value assigned to it
• Eg: a=10 Integer datatype since 10 is integer
• A=12.56 Float datatype since 12.56 is float
• The values of any type can be assigned to a variable in the same
program.
Eg: a=10
print(a) Prints integer value 10
a=12.45
print(a) Prints float value 12.45
Getting input from the user -
input( ) function
The input() function is used to get input
from the user. The default input type is
string. Output:
Example: Enter a: Hello
r = input(“Enter a:”) Hello
print(r)
Example-Python program to print the area of rectangle
OUTPUT: