Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.92 KB

File metadata and controls

39 lines (31 loc) · 1.92 KB

Module 5: Objects

Activity 1: Introduction to objects

  • Understanding the concept of objects and their role in Python.
  • Exploring the syntax for creating objects using dictionaries.
  • Learning about key-value pairs and accessing object properties.
  • Understanding object methods and their usage.

Activity 2: Creating objects

  • Creating objects using classes and instantiation.
  • Defining classes with the class keyword.
  • Initializing object properties in the class constructor (__init__ method).
  • Exploring class methods and attributes.

Activity 3: Object properties and methods

  • Working with object properties and accessing them using dot notation.
  • Modifying object properties and adding new properties dynamically.
  • Understanding the concept of self and its usage in object methods.
  • Exploring built-in Python objects and their methods.

Practice Exercises:

  1. Create a person object:

    • Create a class called Person with properties for name, age, and occupation.
    • Add a method to the class called introduce that prints a message introducing the person.
    • Create an instance of the Person class and call the introduce method.
  2. Calculate the area of a rectangle using an object:

    • Create a class called Rectangle with properties for width and height.
    • Add a method to the class called calculate_area that calculates the area of the rectangle.
    • Create an instance of the Rectangle class and call the calculate_area method.
  3. Create a bank account object:

    • Create a class called BankAccount with properties for account_number, balance, and owner_name.
    • Add methods to the class for deposit, withdraw, and get_balance.
    • Create an instance of the BankAccount class and perform transactions using the methods.

Estimated time to complete this module is approximately 4-6 hours.

To further enhance your learning, here are some additional resources: