Day 11 - Python Homework

Class & Object Practice

In this assignment, you will practice using classes and objects in Python. These exercises will test your understanding of object-oriented programming, constructors, and methods.

Hint: Think about attributes, methods, and how to create multiple objects from a class.

Assignment 01: Student Class

Create a class to store student details.

Objective:

Practice defining a class, constructor, and instance methods.

Instructions:

  • Create a class called Student with attributes name, age, and grade.
  • Define a method display_info() to print all student details.
  • Create at least 2 student objects and call the display_info() method on each.

Assignment 02: Bank Account Class

Simulate a simple bank account using classes.

Objective:

Understand how to manage object attributes and methods.

Instructions:

  • Create a class called BankAccount with attributes account_holder and balance.
  • Define methods deposit(amount) and withdraw(amount) to update balance.
  • Create an object, perform a deposit and a withdrawal, and display the final balance.

If you need help

Ask for help if you are stuck on:

Good luck and enjoy coding! 🚀