Python Classroom notes 29/Apr/2025

Procedural Programming

  • Procedural Programming is like a recipe
    • inputs
    • steps (sequence)
    • output

Object Oriented Programming

  • Object:
    • contains
    • capabilities

Examples

  • Bank Account
BankAccount
  contains:
     account number
     account type
     balance
  characteristics:
    transfer
    withdraw
    deposit
  • Laptop
contains:
  configuration
     cpu
     ram
     storgae
  os
  features
characteristics:
  start
  shutdown
  browser
  ...
  ...
  • Library
book
shelf
newspaper
transaction
librarian
user
  • Object oriented programming has two important concepts
    • Class: Here we are building a cookie cutter/ design (Blueprint)
      • In programming world we write class to specify structure
    • Object: This is what we operate on (cookie/home/ac).
      • We create object from class and object has memory/cpu/resources attached to it.

Writing a class

  • Class is a blueprint
    • members are contents (variables)
    • methods are capabilities (functions)
  • Classes or objects can have relationships
  • To classify these relationship all we have to figure out is
    • is-a relationship
    • has-a relationship
  • Technically in OOD we have 4 types of relationships that can exist
    • Association: uses
    • Aggregation: Weak has-a
    • Composition: Strong has-a
    • Inheritence: is-a

Exercise

  • Identify classes for Restaurant, we are supposed to build a Billing system
    • Restaurant
    • Menu
    • MenuItem
    • Tables list<Table>
    • Order
    • OrderItem
    • Bill
    • Payment
  • Menu
contents:
   menu items

  • Menu Item
contents:
  id
  category
  price
  name
  • Table
content:
   number
   capacity
  • Order
content:
  id
  list<orderItem>
  status
capability:
  generate_bill()
  cancel
  • OrderItem
content:
  id
  menuitem_id
  quanity
  • Bill
contents:
  id
  Order
  amount
  tax
  total
capabilites:
  pay()

UML Diagrams

Principles

  • Abstraction
  • Encapsulation
  • Polymorphism
  • SOLID
  • DuckTyping (Python special)

Refer Here for the notebook created in the class

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube