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

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Play with python lecture 2