0% found this document useful (0 votes)
10 views19 pages

Python 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views19 pages

Python 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

REWA ENGINEERING COLLEGE, REWA (M.P.

Presentation on Python

SUBMITTED TO:- SUBMITTED BY:-


Proff. Shami Pandey Priya Soni
Department of ECE Enrollment no. 0301EC211041
What is python..?

 Python is general purpose interpreted, interactive, object-oriented and high level


programming language. It was created by Guido van Rossum during 1985-90.
 Python is a general purpose programming language that is often applied in scripting roles.
 Python is designed to be highly readable.
 It uses English keywords frequently where ae other languages use punctuation.
Scope of python

 Science – Bioinformatics (It is a filed which uses computer software tools for understanding
biological data)
 Web application Development
 Testing scripts
 System administration
Who uses python today…

 Google makes extensive use of python in its web search system.


 Intel, Cisco, IBM and many other MNC’s use python for hardware testing and web
application development.
 The You tube video sharing service is largely written in python.
Why Python ..?

 Designed to be easy to learn and master


 Highly portable
 Clean, clear syntax
 Runs almost anywhere – high end servers and workstations
 Easy to maintain – Python’s source code is fairly easy to maintain
 Easy to read - Python code is more clearly defined and visible to the eyes.
Math(operators) in python

 Add: +
 Subtract: -
 Divide: /
 Multiply: *
 print 3 + 12 >> 15
 print 12 – 3 >> 9
 print 12 + 3 -7 + 5 >> 13
 print 3 * 12 >> 36
 print 12.0/3.0 >> 4.0
 print 2 < 3 True
 print 2 != 3 True
Data type..

 Booleans – either True or False


 Numbers – can be integers (1 and 2), floats (1.1 and 2.1), fractions (1/2 and 2/3) or even
complex numbers.
 Bytes and byte arrays – image file of any type jpg, jpeg etc
 Lists – ordered sequences o values. e.g. ["apple", "banana", "cherry"]
 Tuples – ordered, immutable sequence of values . E.g. ("apple", "banana", "cherry")
Some examples of Data types..

 String - “Hello”
 Integer – 24
 Float – 3.1415
 List [“a”, “b”, “c”]
 Python can tell the data type using type() function:
 >>> print type(“Hello”)
 Output – type ‘str”
Strings in python

 May hold any data, including embedded nulls


 Declared using either single, double or triple quotes
 >>> s = “ Hello Class”
 >>> s = ‘Hello Class’
Classes and Objects..

 To create a class, use the keyword class


Class MyClass:
x=5
Now we can use the class named MyClass to create objects
 Create an object named p, and print the value of x
P = MyClass()
Print (p.x)

Output - 5
Looping..
Python If..Else

 An "if statement" is written by using the if keyword.


a = 33
b = 200
if b > a:
print("b is greater than a")
Note - Python relies on indentation (whitespace at the beginning of a line) to define scope in
the code. Other programming languages often use curly-brackets for this purpose.
Output - b is greater than a
Elif

 The elif keyword is pythons way of saying "if the previous conditions were not true, then try
this condition".
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
Output - a and b are equal
Else

 The else keyword catches anything which isn't caught by the preceding conditions.
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
Output - a is greater than b
 We can also have an else without the elif :
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")

Output - b is not greater than a


Python For loops..

 A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a
set, or a string).
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)

Output - apple
banana
cherry
Looping Through a String

 Loop through the letters in the word "banana":


for x in "banana":
print(x)

Output –
b
a
n
a
n
a
The break Statement

 With the break statement we can stop the loop before it has looped through all the items:
Exit the loop when x is “banana”:
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
if x == "banana":
break

Output –
apple
banana
Thank You!

You might also like