Engineering college , ajmer
PRESENTATION ON PYTHON
Department of Electronics And Communication Engineering
Presented To:- Presented By:-
Sh. Rajesh Kumar Raj Kamlesh
(Assistant Professor) (17EC29)
1
2
INTRODUCTION TO PYTHON
3
Introduction:
• Python is a general purpose high-level, interpreted, interactive and object-
oriented scripting language.
It uses English keywords frequently where as other languages use punctuation,
and it has fewer syntactical constructions than other languages.
• Python is recommended as first programming language for beginners.
4
Eg: To print Helloworld:
Java:
public class HelloWorld
In python
{ print("Hello World")
p s v main(String[] args)
{
SOP("Hello world");
}}
In C:
#include<stdio.h>
void main()
{printf("Hello world");}
5
• History of Python
• Python was developed by Guido Van Rossam in 1989 while working at National Research
Institute at Netherlands.
• But officially Python was made available to public in 1991. The official Date of Birth for
Python is : Feb 20th 1991.
• Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk,
Unix shell, and other scripting languages.
6
Where we can use Python:
We can use everywhere. The most common important application areas are
1. For developing Desktop Applications
2. For developing web Applications
3. For developing database Applications
4. For Network Programming
5. For developing games
6. For Data Analysis Applications
7. For Machine Learning
8. For developing Artificial Intelligence Applications
9. For IOT
7
Disadvantages of Python
• Python is not as fast as C and C++, It means it is slower than C/C++:
• Does not check variable type at compile time. It use dynamic type so
flexible that Python interpreter cannot check the type for mismatch at
the compile time.
8
Features of Python
• 1. Simple and easy to learn
• 2. Freeware and Open Source
• 3. High Level Programming language
• 4. Platform Independent
• 5.Dynamically Typed
• 6. Protability
• 7.Both Procedure Oriented and Object Oriented
• 8. Interpreted
9
How to Run Python Programs
• There are three way to execute python code they are given below;
• 1)Interactive Mode
• 2)Script Mode
• 3)Using IDE
10
Identifiers
A name in Python program is called identifier.
It can be class name or function name or module name or variable
name.
a = 10
Rules to define identifiers in Python:
1. The only allowed characters in Python are
alphabet symbols(either lower case or upper case)
digits(0 to 9)
underscore symbol(_)
By mistake if we are using any other symbol like $ then we will get
syntax error.
cash = 10
ca$h =20
11
Variables in Python
• Variables are used for store data on memory location
• Variables are nothing but reserved memory locations to store values.
This means that when you create a variable you reserve some space in
memory.
• Based on the data type of a variable, the interpreter allocates memory
and decides what can be stored in the reserved memory. Therefore, by
assigning different data types to variables, you can store integers,
decimals or characters in these variables.
12
13
Keywords in Python(Reserved Words)
• In Python some words are reserved to represent some meaning or functionality.
Such type of words are called Reserved words.
• There are 33 reserved words available in Python.
1. True,False,None
2. and, or ,not,is
3. if,elif,else while,for,break,continue,return,in,yield
4. try,except,finally,raise,assert
5. import,from,as,class,def,pass,global,nonlocal,lambda,del,with
If want see the keyword list type the following
import keyword
keyword.kwlist
14
Input Statements
Reading dynamic input from the keyboard:
• In Python 2 the following 2 functions are available to read dynamic
input from the keyboard.
• raw_input()
• input()
15
Data types
• A variable can hold different types of values. For example, a person's name must
be stored as a string whereas its id must be stored as an integer.
• Python provides various standard data types that define the storage method on
each of them. The data types defined in Python are given below.
1. Numbers
2. String
3. List
4. Tuple
5. set
6. Dictionary
16
Operators:
Operator is a symbol that performs certain operations.
Python provides the following set of operators
1. Arithmetic Operators
2. Relational Operators
3. Equality Operators
4. Logical Operators
5. Assignment Operators
6. Bitwise Operators
7.Ternary Operator
8. Special operators
17
Standard Type Built-in Functions:
• The functions which are coming along with Python software automatically,
are called built in functions or pre defined functions.
• cmp(),repr(),str(),type(), id(),input(),eval().
• Function Operation
• cmp(obj1, obj2) Compares obj1 and obj2, returns integer i where:
i < 0 if obj1 < obj2
i > 0 if obj1 > obj2
i == 0 if obj1 == obj2
• repr(obj) or `obj` Returns evaluatable string representation of obj
• str(obj) Returns printable string representation of obj
• type(obj) Determines type of obj and return type object
18
File Handling:
• To store our data permanently for future purpose. For this requirement we
should go for files.
There are 2 types of files:
1. Text Files:
Usually we can use text files to store character data
eg: abc.txt
2. Binary Files:
Usually we can use binary files to store binary data like images,video files,
audio files etc...
19
Exception Handling:
In any programming language there are 2 types of errors are possible.
1. Syntax Errors
2. Runtime Errors
1.Syntax Errors:
The errors which occurs because of invalid syntax are called syntax errors.
Eg 1:
x=10
if x==10
print("Hello")
SyntaxError: invalid syntax
20
Eg 2:
print "Hello“
SyntaxError: Missing parentheses in call to 'print’ not valid in python 3.0.
• “Programmer is responsible to correct these syntax errors”. Once all syntax errors
are corrected then only program execution will be started.
2. Runtime Errors: (Also known as exceptions)
• While executing the program if something goes wrong because of end user input
or programming logic or memory problems etc., then we will get Runtime Errors.
21
Working of Python Program
22
Conclusion
Python is general purpose, interpreted and objects oriented programming language .
You can enter Python statements interactively from the Python prompt >>>
Python Programs can be written on the script mode and commands can be executed
on the interactive mode.
23
𝙏𝙝 𝙖 𝙣𝙠 𝙔𝙤 𝙪
24