SlideShare a Scribd company logo
Play with Python
     Lecture 2
Agenda
Revision
Object Oriented Programming
Demo 1
Demo 2
Demo 3 (GUI)
Assignment
Next Week !
Revision
Lists
  empty list:
       lst = []
  list of lists:
       lofl = [[1,2],[3,4]]
  list of different types: lst2 = [1, "hi"]
Dictionary:
  empty dictionary:
       d = {}
Object Oriented Programming
Application is a set of objects
Object Oriented Programming
Application is a set of living objects
Object Oriented Programming
Application is a set of living interacting objects
Object Oriented Programming
Application is a set of living interacting objects
Data + Behaviour
Application is a set of living interacting objects
Demo 1 (Animals)
c = Cat()
c.talk()
c.walk()
Demo 1 (Animals)
c = Cat()
c.talk()
c.walk()

d = Duck()
d.talk()
d.fly()
Demo 1 (Animals)
c = Cat()           m = Mouse()
c.talk()            m.die()
c.walk()

d = Duck()
d.talk()
d.fly()
Demo 1 (Animals)
c = Cat()           m = Mouse()
c.talk()            m.die()
c.walk()

d = Duck()
d.talk()
d.fly()
Demo 1 (Animals eating)
c = Cat()
c.talk()
c.walk()
c.eat(m)

c2 = Cat()
c2.eat(b)
Demo 1 (Animals)
c = Cat()           m = Mouse()
c.talk()
c.walk()
c.eat(m)            b = Bread()

c2 = Cat()
c2.eat(b)
Demo 1 Classes (Animals)
class Cat:                     class Mouse:
   def talk(self):                    def die(self):
                                               print " !!   "
        print "    "


   def walk(self):             class Bread:
       print "         "              def die(self):
                                               print “”     ”

   def eat(self, something):
       something.die()
       print "        "
Demo 1: List of Animals
animals = []             animals list is also an
animals.append(Cat())      object of class "List" !
animals.append(Duck())


for a in animals:
  a.talk()
Demo 2 (Computer Device)
Demo 2 (Computer Device)
class Computer:                        Constructor
  def __init__(self, computer_type, basePrice):
    self.computerType = computer_type Member
GUI with PyQt4
GUI Example
dlg = QDialog()


btn = QPushButton("Click Me !", dlg)
btn.clicked.connect(onButtonClicked)


btn2 = QPushButton("Click Me Too !!", dlg)
btn2.move(100,0)
btn2.clicked.connect(onButton2Clicked)


dlg.show()


def onButtonClicked():
  print "Hello World"


def onButton2Clicked():
  btn.close()
GUI Example (Added an image)
dlg = QDialog()                               dlg.show()
dlg.resize(500, 500)

                                              def onButtonClicked():
btn = QPushButton("Click Me !", dlg)            print "Hello World"
btn.clicked.connect(onButtonClicked)
                                              def onButton2Clicked():
                                                btn.close()
btn2 = QPushButton("Click Me Too !!", dlg)
btn2.move(100,0)
btn2.clicked.connect(onButton2Clicked)



label = QLabel("My First GUI program", dlg)
pix = QPixmap("Water lilies.jpg")
label.setPixmap(pix)

More Related Content

PDF
Functional JS for everyone - 4Developers
PDF
Pooja Sharma , BCA Third Year
PPTX
Android Guava
PPTX
Selected Bash shell tricks from Camp CDL breakout group
PDF
Snakes for Camels
PPTX
User journey looking for a security company in leeds
PPTX
User experience wire frames
PDF
Windows 8 UX Guidelines
Functional JS for everyone - 4Developers
Pooja Sharma , BCA Third Year
Android Guava
Selected Bash shell tricks from Camp CDL breakout group
Snakes for Camels
User journey looking for a security company in leeds
User experience wire frames
Windows 8 UX Guidelines

Viewers also liked (7)

PPT
Persona - User Centred Design
PDF
Top 10 UX Guidelines
PDF
PPTX
Defining Personas, A User Experience Approach
PPTX
Persona mapping
PPT
Design Thinking With Persona
PDF
Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
Persona - User Centred Design
Top 10 UX Guidelines
Defining Personas, A User Experience Approach
Persona mapping
Design Thinking With Persona
Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
Ad

Similar to Play with python lecture 2 (20)

ODP
Programming Under Linux In Python
PDF
Python An Intro
PPTX
PRESENTATION ON PYTHON.pptx
PDF
Intro to Python
ODP
An Intro to Python in 30 minutes
PPT
Python Kick Start
PDF
Python Lab Manual for First year Engineering students
PDF
Python Part 1
PPTX
Python 101++: Let's Get Down to Business!
PDF
Lecture1_cis4930.pdf
PDF
Intermediate python
PPT
Python for Engineers and Architects Stud
PPT
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
PPTX
python-an-introduction
KEY
Charming python
PPTX
Intro to Python (High School) Unit #2
PDF
PDF
Python
PDF
Python-Magnitia-ToC.pdf
PPTX
beginners_python_cheat_sheet_pcc_all (3).pptx
Programming Under Linux In Python
Python An Intro
PRESENTATION ON PYTHON.pptx
Intro to Python
An Intro to Python in 30 minutes
Python Kick Start
Python Lab Manual for First year Engineering students
Python Part 1
Python 101++: Let's Get Down to Business!
Lecture1_cis4930.pdf
Intermediate python
Python for Engineers and Architects Stud
FALLSEM2022-23_ITA3007_ETH_VL2022230100613_Reference_Material_I_23-09-2022_py...
python-an-introduction
Charming python
Intro to Python (High School) Unit #2
Python
Python-Magnitia-ToC.pdf
beginners_python_cheat_sheet_pcc_all (3).pptx
Ad

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Encapsulation theory and applications.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Big Data Technologies - Introduction.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
Spectroscopy.pptx food analysis technology
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Encapsulation theory and applications.pdf
Machine Learning_overview_presentation.pptx
cuic standard and advanced reporting.pdf
sap open course for s4hana steps from ECC to s4
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Big Data Technologies - Introduction.pptx
The AUB Centre for AI in Media Proposal.docx

Play with python lecture 2