Python Practice › OOP Programs › Program 41

VIPCustomer with credit

EasyOOP Programs · 41 of 48

Create VIPCustomer (inherits Customer) with credit_limit and discount_rate, and a method for available credit.

Advertisement
Output
12000 850.0

Approach

  1. Available credit = credit limit + balance.

Solution

Python
class Customer:    def __init__(self, name, balance=0):        self.name, self.balance = name, balance class VIPCustomer(Customer):    def __init__(self, name, balance, credit_limit, discount_rate):        super().__init__(name, balance)        self.credit_limit, self.discount_rate = credit_limit, discount_rate     def available_credit(self):        return self.balance + self.credit_limit     def price_after_discount(self, price):        return price * (1 - self.discount_rate / 100) v = VIPCustomer("Meena", 2000, 10000, 15)print(v.available_credit(), v.price_after_discount(1000))
Output
12000 850.0

Learn the concept

New to this topic? Read the lesson, then come back.

More oop programs

← All 48 OOP Programs

Leave a Comment