SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (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
 

Similar 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

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...vershagrag
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...jabtakhaidam7
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxpritamlangde
 

Último (20)

FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
Jaipur ❤CALL GIRL 0000000000❤CALL GIRLS IN Jaipur ESCORT SERVICE❤CALL GIRL IN...
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .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