SlideShare a Scribd company logo
1 of 21
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

Viewers also liked

Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
Anna Dahlström
 

Viewers also liked (7)

Persona - User Centred Design
Persona - User Centred Design Persona - User Centred Design
Persona - User Centred Design
 
Top 10 UX Guidelines
Top 10 UX GuidelinesTop 10 UX Guidelines
Top 10 UX Guidelines
 
Personas
PersonasPersonas
Personas
 
Defining Personas, A User Experience Approach
Defining Personas, A User Experience ApproachDefining Personas, A User Experience Approach
Defining Personas, A User Experience Approach
 
Persona mapping
Persona mappingPersona mapping
Persona mapping
 
Design Thinking With Persona
Design Thinking With PersonaDesign Thinking With Persona
Design Thinking With Persona
 
Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
 

Similar to Play with python lecture 2 (10)

Tip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python TypingTip Top Typing - A Look at Python Typing
Tip Top Typing - A Look at Python Typing
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Class 29: Inheritance
Class 29: InheritanceClass 29: Inheritance
Class 29: Inheritance
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
Clojure入門
Clojure入門Clojure入門
Clojure入門
 
Python basic
Python basic Python basic
Python basic
 
Probabilistic Programming in Scala
Probabilistic Programming in ScalaProbabilistic Programming in Scala
Probabilistic Programming in Scala
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Play with python lecture 2