SlideShare uma empresa Scribd logo
1 de 38
PROJECT
PRESENTATIONby Diwakar raja
HISTORY
• Python was conceived in the late 1980’s by Guido
van Rossum
• Developed at Centrum Wiskunde & Informatica in
the Netherlands
• Influenced by ABC programming language,
MODULA 2+ and MODULA 3
VERSIONS
• The first public version of python was released on
February 20, 1991
• Version 1.0 (1994 - 2000)
• Version 2.0 (2000 - 2008)
• Version 3.0 (2008 - Present day)
PARADIGM /
CLASSIFICATION
• Python supports multiple paradigms
• More Object Oriented
• Imperative
• Functional
• Procedural
• Reflective
COMPILERS
• Python source code is automatically compiled when
you install python on your computer
• Mac OS, latest Linux distributions and UNIX comes
with python pre-installed
• Python can be downloaded from
https://www.python.org/downloads/
MORE COMPILERS
There are various compilers for various
implementations of python.
Few compilers for the default implementation
(Cpython) :
• Nuitka - http://nuitka.net/pages/download.html
• Pyjs - http://pyjs.org/Download.html
APPLICATIONS
• Web and Internet Development
• Scientific and Numeric computing
• Software Development
• GUI Development
• Rapid Prototyping
• Writing Scripts
• Data Analysis
PROGRAM STRUCTURE
• Similar to other Object oriented programming
languages
• Importing libraries
• Initializing Variables
• Initializing Classes and Objects
• Structured with indentations
DATA TYPES
• Numbers
• Boolean
• String
• Lists
• Tuples
• Dictionaries
NUMBERS
• Any number you enter in Python will be interpreted as a
number; you are not required to declare what kind of data type
you are entering
Type Format Description
int a=10 Signed integer
long a=345L Long integer
float a=45.67 Floating point real values
complex a=3.14J Real and imaginary values
BOOLEAN
• The Boolean data type can be one of two values,
either True or False
• We can declare them as following
y=True
z=False
• Another special data type we have to know about is none. It holds
no value and is declared as
x=none
STRING
• Create string variables by enclosing characters in quotes
Declared as:
firstName = 'john'
lastName = "smith"
message = """This is a string that will span across multiple lines.
Using newline characters and no spaces for the next lines.
The end of lines within this string also count as a newline when
printed"""
LISTS
• A list can contain a series of values. List variables are declared by using
brackets [] following the variable name.
# w is an empty list
w=[]
# x has only one member
x=[3.0]
# y is a list of numbers
y=[1,2,3,4,5]
# z is a list of strings and other lists
z=['first',[],'second',[1,2,3,4],'third']
TUPLE
• Tuples are a group of values like a list and are
manipulated in similar ways. But, tuples are fixed in size
once they are assigned. In Python the fixed size is
considered immutable as compared to a list that is
dynamic and mutable. Tuples are defined by parenthesis
().
Example:
myGroup = ('Rhino', 'Grasshopper', 'Flamingo', 'Bongo')
DICTIONARIES
• A Python dictionary is a group of key-value
pairs. The elements in a dictionary are
indexed by keys. Keys in a dictionary are
required to be unique.
Example:
words = { 'girl': 'Maedchen', 'house': 'Haus', 'death': 'Tod' }
USER DEFINED DATA
TYPES
Classes and Objects:
• Objects are an encapsulation of variables and functions into a
single entity.
• Objects get their variables and functions from classes.
• Classes are essentially a template to create your objects
CLASSES AND OBJECTS
Examples:
The variable "myobjectx" holds an object of the class "MyClass" that contains the variable
and the function defined within the class called "MyClass".
CLASSES AND OBJECTS
Examples:
To access a function inside of an object you use notation similar to accessing a variable
SEQUENCE CONTROL
• Expressions:
An expression is an instruction that combines values and
operators and always evaluates down to a single value.
For example, this is an expression:
2+2
• Statements:
A Python statement is pretty much everything else that isn't an expression.
Here's an assignment statement:
spam=2+2
IF STATEMENTS
Perhaps the most well-known statement type is the if stateme
For example:
if temp < 10:
print "It is cold!”
Output:
It is cold!
IF ELSE STATEMENTS
Example:
temp = 20
if temp < 10:
print "It is cold!"
else:
print "It feels good!”
Output:
It feels good!
FOR STATEMENTS
Python’s for statement iterates over the items of any sequence (a list
or a string), in the order that they appear in the sequence.
For example:
for i in [0,1,2,3,4]:
print i
Output:
0
1
2
3
4
WHILE LOOPS
A while loop repeats a sequence of statements until some condition become
For example:
x = 5
while x > 0:
print (x)
x = x – 1
Output:
5
4
3
2
1
BREAK STATEMENT
Python includes statements to exit a loop (either a for loop or
while loop) prematurely. To exit a loop, use the break stateme
x = 5
while x > 0:
print x
break
x = 1
print x
Output:
5
CONTINUE STATEMENT
The continue statement is used in a while or for loop to take the control to the
of the loop without executing the rest statements inside the loop. Here is a si
example.
for x in range(6):
if (x == 3 or x==6):
continue
print(x)
Output:
0
1
2
4
5
INPUT/OUTPUT
There will be situations where your program has to interact with the use
example, you would want to take input from the user and then print som
results back. We can achieve this using the input() function and print() f
respectively.
Example:
something = input("Enter text: “)
print(something)
Output:
Enter text: Sir
Sir
FILE INPUT/OUTPUT
Reading and Writing Text from a File:
In order to read and write a file, Python built-in
function open() is used to open the file. The open()function
creates a file object.
Syntax:
file object = open(file_name [, access_mode])
• First argument file_name represents the file name that
you want to access.
• Second argument access_mode determines, in which
mode the file has to be opened, i.e., read, write, append,
etc.
FILE INPUT
Example:
file_input = open("simple_file.txt",'r')
all_read = file_input.read()
print all_read
file_input.close()
Output:
Hello
Hi
FILE OUTPUT
Example:
text_file = open("writeit.txt",'w')
text_file.write("Hello")
text_file.write("Hi")
text_file.close()
SUB-PROGRAM CONTROL
abs() dict() help() min() setattr() chr() repr() round()
all() dir() hex() next() slice() type() compile() delattr()
any() divmod() id() object() sorted() list() globals() hash()
ascii() enumerate() input() oct()
staticmethod(
)
range() map() print()
bin() eval() int() open() str() vars() reversed() set()
bool() exec() isinstance() ord() sum() zip() max() float()
bytearray() filter() issubclass() pow() super()
classmethod(
)
complex() format()
Some built-in functions:
USER DEFINED
FUNCTIONS
A function is defined in Python by the following format:
def functionname(arg1, arg2, ...):
statement1
statement2
…
Example:
def functionname(arg1,arg2):
return arg1+ arg2
t = functionname(24,24) # Result: 48
ENCAPSULATION
• In an object oriented python program, you can restrict access to methods
and variables. This can prevent the data from being modified by accident
and is known as encapsulation.
• Instance variable names starting with two underscore characters cannot be
accessed from outside of the class.
Example:
class MyClass:
__variable = "blah"
def function(self):
print self.__variable
myobjectx = MyClass()
myobjectx.__variable #will give an error
myobjectx.function() #will output “blah”
INHERITANCE
Inheritance is used to inherit another class' members, including fields and
methods. A sub class extends a super class' members.
Example:
class Parent:
variable = "parent"
def function(self):
print self.variable
class Child(Parent):
variable2 = "blah"
childobjectx = Child()
childobjectx.function()
Output:
Parent
EXAMPLE PROGRAM
PROGRAMMING PROJECT
http://cs.newpaltz.edu/~anbarasd1/simple3/
APPLET

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Course 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment VariablesCourse 102: Lecture 11: Environment Variables
Course 102: Lecture 11: Environment Variables
 
Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
 
Python course Day 1
Python course Day 1Python course Day 1
Python course Day 1
 
Day3
Day3Day3
Day3
 
Day2
Day2Day2
Day2
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling
 
4 b file-io-if-then-else
4 b file-io-if-then-else4 b file-io-if-then-else
4 b file-io-if-then-else
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Python basics
Python basicsPython basics
Python basics
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
Python modules
Python modulesPython modules
Python modules
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
Mysql
MysqlMysql
Mysql
 
Python - Lecture 9
Python - Lecture 9Python - Lecture 9
Python - Lecture 9
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring
 
Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking Help
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 

Semelhante a Presentation new (20)

Programming in Python
Programming in Python Programming in Python
Programming in Python
 
ENGLISH PYTHON.ppt
ENGLISH PYTHON.pptENGLISH PYTHON.ppt
ENGLISH PYTHON.ppt
 
manish python.pptx
manish python.pptxmanish python.pptx
manish python.pptx
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Python Basics
Python BasicsPython Basics
Python Basics
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Lenguaje Python
Lenguaje PythonLenguaje Python
Lenguaje Python
 
pysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
pysdasdasdsadsadsadsadsadsadasdasdthon1.pptpysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
pysdasdasdsadsadsadsadsadsadasdasdthon1.ppt
 
coolstuff.ppt
coolstuff.pptcoolstuff.ppt
coolstuff.ppt
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Introductio_to_python_progamming_ppt.ppt
Introductio_to_python_progamming_ppt.pptIntroductio_to_python_progamming_ppt.ppt
Introductio_to_python_progamming_ppt.ppt
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Kavitha_python.ppt
Kavitha_python.pptKavitha_python.ppt
Kavitha_python.ppt
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
 
Python ppt
Python pptPython ppt
Python ppt
 
1. python programming
1. python programming1. python programming
1. python programming
 

Último

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 

Último (20)

Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 

Presentation new

  • 2. HISTORY • Python was conceived in the late 1980’s by Guido van Rossum • Developed at Centrum Wiskunde & Informatica in the Netherlands • Influenced by ABC programming language, MODULA 2+ and MODULA 3
  • 3. VERSIONS • The first public version of python was released on February 20, 1991 • Version 1.0 (1994 - 2000) • Version 2.0 (2000 - 2008) • Version 3.0 (2008 - Present day)
  • 4. PARADIGM / CLASSIFICATION • Python supports multiple paradigms • More Object Oriented • Imperative • Functional • Procedural • Reflective
  • 5. COMPILERS • Python source code is automatically compiled when you install python on your computer • Mac OS, latest Linux distributions and UNIX comes with python pre-installed • Python can be downloaded from https://www.python.org/downloads/
  • 6. MORE COMPILERS There are various compilers for various implementations of python. Few compilers for the default implementation (Cpython) : • Nuitka - http://nuitka.net/pages/download.html • Pyjs - http://pyjs.org/Download.html
  • 7. APPLICATIONS • Web and Internet Development • Scientific and Numeric computing • Software Development • GUI Development • Rapid Prototyping • Writing Scripts • Data Analysis
  • 8. PROGRAM STRUCTURE • Similar to other Object oriented programming languages • Importing libraries • Initializing Variables • Initializing Classes and Objects • Structured with indentations
  • 9.
  • 10.
  • 11. DATA TYPES • Numbers • Boolean • String • Lists • Tuples • Dictionaries
  • 12. NUMBERS • Any number you enter in Python will be interpreted as a number; you are not required to declare what kind of data type you are entering Type Format Description int a=10 Signed integer long a=345L Long integer float a=45.67 Floating point real values complex a=3.14J Real and imaginary values
  • 13. BOOLEAN • The Boolean data type can be one of two values, either True or False • We can declare them as following y=True z=False • Another special data type we have to know about is none. It holds no value and is declared as x=none
  • 14. STRING • Create string variables by enclosing characters in quotes Declared as: firstName = 'john' lastName = "smith" message = """This is a string that will span across multiple lines. Using newline characters and no spaces for the next lines. The end of lines within this string also count as a newline when printed"""
  • 15. LISTS • A list can contain a series of values. List variables are declared by using brackets [] following the variable name. # w is an empty list w=[] # x has only one member x=[3.0] # y is a list of numbers y=[1,2,3,4,5] # z is a list of strings and other lists z=['first',[],'second',[1,2,3,4],'third']
  • 16. TUPLE • Tuples are a group of values like a list and are manipulated in similar ways. But, tuples are fixed in size once they are assigned. In Python the fixed size is considered immutable as compared to a list that is dynamic and mutable. Tuples are defined by parenthesis (). Example: myGroup = ('Rhino', 'Grasshopper', 'Flamingo', 'Bongo')
  • 17. DICTIONARIES • A Python dictionary is a group of key-value pairs. The elements in a dictionary are indexed by keys. Keys in a dictionary are required to be unique. Example: words = { 'girl': 'Maedchen', 'house': 'Haus', 'death': 'Tod' }
  • 18. USER DEFINED DATA TYPES Classes and Objects: • Objects are an encapsulation of variables and functions into a single entity. • Objects get their variables and functions from classes. • Classes are essentially a template to create your objects
  • 19. CLASSES AND OBJECTS Examples: The variable "myobjectx" holds an object of the class "MyClass" that contains the variable and the function defined within the class called "MyClass".
  • 20. CLASSES AND OBJECTS Examples: To access a function inside of an object you use notation similar to accessing a variable
  • 21. SEQUENCE CONTROL • Expressions: An expression is an instruction that combines values and operators and always evaluates down to a single value. For example, this is an expression: 2+2 • Statements: A Python statement is pretty much everything else that isn't an expression. Here's an assignment statement: spam=2+2
  • 22. IF STATEMENTS Perhaps the most well-known statement type is the if stateme For example: if temp < 10: print "It is cold!” Output: It is cold!
  • 23. IF ELSE STATEMENTS Example: temp = 20 if temp < 10: print "It is cold!" else: print "It feels good!” Output: It feels good!
  • 24. FOR STATEMENTS Python’s for statement iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence. For example: for i in [0,1,2,3,4]: print i Output: 0 1 2 3 4
  • 25. WHILE LOOPS A while loop repeats a sequence of statements until some condition become For example: x = 5 while x > 0: print (x) x = x – 1 Output: 5 4 3 2 1
  • 26. BREAK STATEMENT Python includes statements to exit a loop (either a for loop or while loop) prematurely. To exit a loop, use the break stateme x = 5 while x > 0: print x break x = 1 print x Output: 5
  • 27. CONTINUE STATEMENT The continue statement is used in a while or for loop to take the control to the of the loop without executing the rest statements inside the loop. Here is a si example. for x in range(6): if (x == 3 or x==6): continue print(x) Output: 0 1 2 4 5
  • 28. INPUT/OUTPUT There will be situations where your program has to interact with the use example, you would want to take input from the user and then print som results back. We can achieve this using the input() function and print() f respectively. Example: something = input("Enter text: “) print(something) Output: Enter text: Sir Sir
  • 29. FILE INPUT/OUTPUT Reading and Writing Text from a File: In order to read and write a file, Python built-in function open() is used to open the file. The open()function creates a file object. Syntax: file object = open(file_name [, access_mode]) • First argument file_name represents the file name that you want to access. • Second argument access_mode determines, in which mode the file has to be opened, i.e., read, write, append, etc.
  • 30. FILE INPUT Example: file_input = open("simple_file.txt",'r') all_read = file_input.read() print all_read file_input.close() Output: Hello Hi
  • 31. FILE OUTPUT Example: text_file = open("writeit.txt",'w') text_file.write("Hello") text_file.write("Hi") text_file.close()
  • 32. SUB-PROGRAM CONTROL abs() dict() help() min() setattr() chr() repr() round() all() dir() hex() next() slice() type() compile() delattr() any() divmod() id() object() sorted() list() globals() hash() ascii() enumerate() input() oct() staticmethod( ) range() map() print() bin() eval() int() open() str() vars() reversed() set() bool() exec() isinstance() ord() sum() zip() max() float() bytearray() filter() issubclass() pow() super() classmethod( ) complex() format() Some built-in functions:
  • 33. USER DEFINED FUNCTIONS A function is defined in Python by the following format: def functionname(arg1, arg2, ...): statement1 statement2 … Example: def functionname(arg1,arg2): return arg1+ arg2 t = functionname(24,24) # Result: 48
  • 34. ENCAPSULATION • In an object oriented python program, you can restrict access to methods and variables. This can prevent the data from being modified by accident and is known as encapsulation. • Instance variable names starting with two underscore characters cannot be accessed from outside of the class. Example: class MyClass: __variable = "blah" def function(self): print self.__variable myobjectx = MyClass() myobjectx.__variable #will give an error myobjectx.function() #will output “blah”
  • 35. INHERITANCE Inheritance is used to inherit another class' members, including fields and methods. A sub class extends a super class' members. Example: class Parent: variable = "parent" def function(self): print self.variable class Child(Parent): variable2 = "blah" childobjectx = Child() childobjectx.function() Output: Parent