Friday, November 22, 2024

CLASSES AND OBJECTS TASKS

1.Create a person class. Include attributes like name, country and date of birth.
Implement a method to determine the person’s age.
#Code :

from datetime import date
class person:
    def getdata(self):
        dt=date.today()
        self.name=input("Enter Your Name : ").capitalize()
        dob_in=input("Enter Your DOB (yyyy-mm-dd) : ")
        self.dob=date.fromisoformat(dob_in)
        self.country=input("Enter Your Country : ").capitalize()
        self.age=dt.year-self.dob.year - ((dt.month,dt.day)<(self.dob.month,self.dob.day))
    def display(self):
        print(f"Name : {self.name}")
        print(f"DOB : {self.dob.strftime("%d-%m-%Y")}")
        print(f"Age : {self.age}")
        print(f"Country : {self.country}")
p=person()
p.getdata()
print("*************************************")
p.display()

2. Create a class representing a Circle. Include methods to calculate its area and
perimeter.
#Code :

class circle:
    def area(self,r):
        return 3.14*r*r
    def peri(self,r):
        return 2*3.14*r
c=circle()
r=int(input("Enter the Radius : "))
print("CIRCLE")
print("Area : ",c.area(r))
print(f"Perimeter : {c.peri(r) : .2f}")

3. Write a Python program to create a class representing a bank. Include methods for managing customer accounts and transactions.

#Code :

from datetime import date
import random as r

class bank:
    
    def __init__(self):
        self.ac=r.sample(range(10000000,100000000), 1)
        self.ifsc="BOT02580"
        self.branch="Udumalpet"
        self.balance=0
        self.trans={ "Deposit" : 0,"Withdraw" : 0}
        self.t1,self.t2=[],[]
    
    def customer(self):
        print("****************************************")
        print("\tCUSTOMER ACCOUNT")
        print("****************************************")
        self.name=input("Enter the Customer Name : ").upper()
        self.occup=input("Enter the Occupation : ").capitalize()
        self.dob=date.fromisoformat(input("Enter the DOB [yyyy-mm-dd] : "))
        self.add=input("Enter the Address : ").strip().split(',')
        
    def deposit(self):
        print("****************************************")
        print("\tDEPOSITION PROCESS")
        print("****************************************")
        t=int(input("Enter the Deposit Amount : "))
        self.balance+=t
        self.t1.append(t)
        self.trans["Deposit"]=self.t1

    def withdraw(self):
        print("****************************************")
        print("\tWITHDRAWAL PROCESS")
        print("****************************************")
        t=int(input("Enter the Withdrawal Amount : "))
        if t>self.balance:
            print("\t**INSUFFICIENT BALANCE")
        else:
            self.balance-=t
            self.t2.append(t)
            self.trans["Withdraw"]=self.t2

    def transaction(self):
        print("****************************************")
        print("\tTRANSACTION HISTORY")
        print("****************************************")
        ch=input("Which details you want to know ? Deposit/Withdraw : ").capitalize()
        if self.trans[ch]!=0:
            print(f"Your {ch} History")
            print("---------------------------")
            for i in self.trans[ch]:
                print(i)
        else:
            print(f"{ch} history is empty ")

    def account(self):
        print("****************************************")
        print("\tACCOUNT DETAILS")
        print("****************************************")
        print(f"A/C No : {self.ac}")
        print(f"Holder Name : {self.name}")
        print(f"DOB : {self.dob}")
        print(f"Address : {self.add}")
        print(f"Occupation : {self.occup}")
        print(f"IFSC Code : {self.ifsc}")
        print(f"Branch : {self.branch}")
        print(f"Balance : {self.balance}")

c1=bank()
print("****************************************")
print("\tBANK OF TAMILNADU")
print("****************************************")
print("Welcomes You !\n")
while True:
    c=int(input("\t*MENU*\n1.NEW ACCOUNT\n2.DEPOSIT\n3.WITHDRAW\n4.TRANSACTION\n5.YOUR ACCOUNT\n6.EXIT\nEnter your choice : "))
    match c:
        case 1:
            c1.customer()
        case 2:
            c1.deposit()
        case 3:
            c1.withdraw()
        case 4:
            c1.transaction()
        case 5:
            c1.account()
        case 6:
            exit(0)
            print("\tTHANK YOU")
        case _:
            print("INVALID OPTION : TRY AGAIN")

4. Write a Python program to create a class representing a shopping cart.
Include methods for adding and removing items, and calculating the total price.
#Code :

class shopping_cart:
    def __init__(self):
        self.cus_items,self.brands,self.cat=[],[],[]
        self.accessories={
            "Electronic":{
                "Tv" : {
                    "Panasonic":25000,
                    "Redmi": 30000,
                    "Philips" : 20000
                    },
                "Refrigerator":{
                    "Whirlpool" : 35000,
                    "Lg" : 40000,
                    "Haier" : 50000
                    },
                "Speaker" : {
                    "Sony" : 16000,
                    "JBL" : 20000,
                    "TBL" : 12000
                    }
                },
            "Cosmetics":{
                "Skin" : {
                    "Facewash" : 3000,
                    "Sunscreen" : 2500,
                    "moisturizer" : 2000
                    },
                "Hair" : {
                    "Shampoo" : 3500,
                    "Conditioner" : 3000,
                    "Serum" : 2000
                    },
                "Makeup" : {
                    "Eyeliner" : 1500,
                    "Lipstick" : 1000,
                    "Nailpolish" : 1200
                    }
                },
            "Smart" : {
                "Watch" : {
                    "Noise" : 1500,
                    "Zora" : 1000,
                    "Boat" : 2000
                    },
                "Assistant" : {
                    "Google" : 10000,
                    "Alexa" : 5500,
                    "Mi" : 4000
                    },
                "Lock" : {
                    "Denler" : 20000,
                    "Lg" : 14500,
                    "Zemote" : 33000
                    }
                }
            }
    def add_items(self):
        print("**************************************")
        print("\tCATEGORIES")
        print("**************************************")
        for category in self.accessories:
            print(category)
        self.ch=input("Choose Your Category : ").capitalize()
        print("\n**************************************")
        print(f"\t{self.ch.upper()} BRANDS")
        print("**************************************")
        for brand in self.accessories[self.ch]:
                print(brand)
        self.brand=input("Choose Your Brand : ").capitalize()
        print("\n**************************************")
        print(f"\t{self.brand.upper()} PRODUCTS")
        print("**************************************")
        for product in self.accessories[self.ch][self.brand]:
                print(product)
        self.product=input("Choose Your Product : ").capitalize()
        print("**************************************")
        print(f"Price of {self.product} : {self.accessories[self.ch][self.brand][self.product]}")
        cart=input("Do You Want to Add to Cart : Y/N ? ").upper()
        if cart=='Y':
            self.cat.append(self.ch)
            self.brands.append(self.brand)
            self.cus_items.append(self.product)
            print("\n\t*SUCCESSFULLY ADDED TO CART*")

    def remove_items(self):
        if len(self.cus_items)==0 :
            print("*Your cart is empty*")
        else:
            print("**************************************")
            print("\tYOUR CART ITEMS")
            print("**************************************")
            for i in self.cus_items:
                print(i)
            self.product=input("Enter the Product to remove from Cart : ").capitalize()
            t=self.cus_items.index(self.product)
            self.cat.pop(t)
            self.brands.pop(t)
            self.cus_items.pop(t)
            print("\n\t*ITEM REMOVED SUCCESSFULLY*")

    def display(self):
        tot=0
        print("\n**************************************")
        print("\tMY CART")
        print("**************************************")
        if len(self.cus_items)==0 :
            print("*Your cart is empty*")
        else:
            print("\nItem\tPrice")
            print("----------------------")
            for i in self.cus_items:
                t=self.cus_items.index(i)
                print(f"{i}\t{self.accessories[self.cat[t]][self.brands[t]][i]}")
                tot+=self.accessories[self.cat[t]][self.brands[t]][i]
            print("----------------------")
            print(f"      Total :  {tot}")
            print("----------------------")
        

#Main_Code
try:
    print("*************************************************")
    print("\tWELCOME TO RAHUL MART")
    print("*************************************************")
    s=shopping_cart()
    while True:
        d=int(input("\n\t*MENU*\n**************************************\n1.ADD ITEM TO CART\n2.REMOVE ITEM FROM CART\n3.YOUR CART ITEMS\n4.EXIT\nEnter Your Choice : "))
        match d:
            case 1:
                s.add_items()
            case 2 :
                s.remove_items()
            case 3:
                s.display()
            case 4:
                exit(0)
                print("\t***THANK YOU FOR CHOOSING OUR SERVICE***")
            case _:
                print("\t*Invalid Choice : Try Again*")
except:
    print("ERROR FOUND : 403")

5. Write a Python program to create a calculator class. Include methods for
basic arithmetic operations.
#Code :

class calculator:
    def add(self,a,b):
        return a+b
    def sub(self,a,b):
        return a-b
    def mul(self,a,b):
        return a*b
    def div(self,a,b):
        return a/b
    def mod(self,a,b):
        return a%b
cal=calculator()
while True:
    n1=int(input("Enter Value 1 : "))
    n2=int(input("Enter Value 2 : "))
    print(f"\nValue 1 : {n1}\nValue 2 : {n2}")
    ch=int(input("\n\tMENU\n1.ADDITION\n2.SUBTRACTION\n3.MULTIPLICATION\n4.DIVISION\n5.MODILUS\n6.EXIT\n\nEnter Your Choice : "))
    match ch:
        case 1:
            print(f"Addition : {cal.add(n1,n2)}\n")
        case 2:
            print(f"Subtraction : {cal.sub(n1,n2)}\n")
        case 3:
            print(f"Multiplication : {cal.mul(n1,n2)}\n")
        case 4:
            print(f"Division : {cal.div(n1,n2)}\n")
        case 5:
            print(f"Modulus : {cal.mod(n1,n2)}\n")
        case 6:
            exit(0)
        case _:
            print("Invalid Choice : Try Again")


6. Write a Python program to create a class that represents a shape. Include
methods to calculate its area and perimeter. Implement subclasses for different
shapes like circle, triangle, and square.
#Code :

from abc import abstractmethod
class shapes:
    @abstractmethod
    def area(self):
        pass
    
    @abstractmethod
    def peri(self):
        pass
    
    def display(self,area,peri):
        print(f"Area : {area}")
        print(f"Perimeter : {peri : .2f}")

class circle(shapes):
    def getdata(self):
        self.r=int(input("Enter the Radius : "))
    def area(self):
        return 3.14*self.r*self.r
    def peri(self):
        return 2*3.14*self.r

class triangle(shapes):
    def getdata(self):
        self.h=int(input("Enter the Height : "))
        self.b=int(input("Enter the Breath : "))
        self.s1=int(input("Enter the Side 1 : "))
        self.s2=int(input("Enter the Side 2 : "))
    def area(self):
        return 0.5*self.h*self.b
    def peri(self):
        return self.s1+self.s2+self.b

class square(shapes):
    def getdata(self):
        self.a=int(input("Enter the Side : "))
    def area(self):
        return self.a*self.a
    def peri(self):
        return 4*self.a

#Main Code
c=circle()
t=triangle()
s=square()
for o in c,t,s:
    name=type(o).__name__.upper()
    print(name)
    print("************************************")
    o.getdata()
    o.display(o.area(),o.peri())
    print("************************************")


7. Write a Python program to create a class representing a bank. Include
methods for managing customer accounts and transactions.
#Code :

from datetime import date
import random as r

class bank:
    
    def __init__(self):
        self.ac=r.sample(range(10000000,100000000), 1)
        self.ifsc="BOT02580"
        self.branch="Udumalpet"
        self.balance=0
        self.trans={ "Deposit" : 0,"Withdraw" : 0}
        self.t1,self.t2=[],[]
    
    def customer(self):
        print("****************************************")
        print("\tCUSTOMER ACCOUNT")
        print("****************************************")
        self.name=input("Enter the Customer Name : ").upper()
        self.occup=input("Enter the Occupation : ").capitalize()
        self.dob=date.fromisoformat(input("Enter the DOB [yyyy-mm-dd] : "))
        self.add=input("Enter the Address : ").strip().split(',')
        
    def deposit(self):
        print("****************************************")
        print("\tDEPOSITION PROCESS")
        print("****************************************")
        t=int(input("Enter the Deposit Amount : "))
        self.balance+=t
        self.t1.append(t)
        self.trans["Deposit"]=self.t1

    def withdraw(self):
        print("****************************************")
        print("\tWITHDRAWAL PROCESS")
        print("****************************************")
        t=int(input("Enter the Withdrawal Amount : "))
        if t>self.balance:
            print("\t**INSUFFICIENT BALANCE")
        else:
            self.balance-=t
            self.t2.append(t)
            self.trans["Withdraw"]=self.t2

    def transaction(self):
        print("****************************************")
        print("\tTRANSACTION HISTORY")
        print("****************************************")
        ch=input("Which details you want to know ? Deposit/Withdraw : ").capitalize()
        if self.trans[ch]!=0:
            print(f"Your {ch} History")
            print("---------------------------")
            for i in self.trans[ch]:
                print(i)
        else:
            print(f"{ch} history is empty ")

    def account(self):
        print("****************************************")
        print("\tACCOUNT DETAILS")
        print("****************************************")
        print(f"A/C No : {self.ac}")
        print(f"Holder Name : {self.name}")
        print(f"DOB : {self.dob}")
        print(f"Address : {self.add}")
        print(f"Occupation : {self.occup}")
        print(f"IFSC Code : {self.ifsc}")
        print(f"Branch : {self.branch}")
        print(f"Balance : {self.balance}")

c1=bank()
print("****************************************")
print("\tBANK OF TAMILNADU")
print("****************************************")
print("Welcomes You !\n")
while True:
    c=int(input("\t*MENU*\n1.NEW ACCOUNT\n2.DEPOSIT\n3.WITHDRAW\n4.TRANSACTION\n5.YOUR ACCOUNT\n6.EXIT\nEnter your choice : "))
    match c:
        case 1:
            c1.customer()
        case 2:
            c1.deposit()
        case 3:
            c1.withdraw()
        case 4:
            c1.transaction()
        case 5:
            c1.account()
        case 6:
            exit(0)
            print("\tTHANK YOU")
        case _:
            print("INVALID OPTION : TRY AGAIN")


8. Create a Vehicle class with max_speed and mileage instance attributes.
#Code :

class vehicle:
    def __init__(self):
        self.model=input("Enter the Car Model : ")
        self.maxspeed=int(input("Enter the Max Speed : "))
        self.miles=int(input("Enter the Mileage : "))
        print("********************************************")
    def show(self):
        print(f" Car Model : {self.model}")
        print(f"Max Speed : {self.maxspeed}")
        print(f"Mileage : {self.miles}")
        print("********************************************")

print("********************************************")
print("\tVEHICLE RECORD")
print("********************************************")
c1=vehicle()
c2=vehicle()
c3=vehicle()
print("********************************************")
c1.show()
c2.show()
c3.show()
        
9. Create Student Class
#Code :

class student:
    def getdata(self):
        self.name=input("Enter the Name : ").capitalize()
        self.cls=input("Enter the Class (Roman) : ").upper()
        self.rno=input("Enter the Roll No : ")
        self.fn=input("Enter the Father's Name : ").capitalize()
        self.mob=input("Enter Father's Mobile No : ")
        self.foccupy=input("Enter Father's Occupation : ").capitalize()
        self.door=input("Enter Door No : ")
        self.town=input("Enter Town : ").capitalize()
        self.pin=input("Enter the Pincode : ")

    def show(self):
        print("***********************************************")
        print("\tSTUDENT DETAILS")
        print("***********************************************")
        print(f"Name                : {self.name}")
        print(f"Class                 : {self.cls}")
        print(f"Roll No             : {self.rno}")
        print(f"Father's Name : {self.fn}")
        print(f"Mobile              : {self.mob}")
        print(f"Occupation      : {self.foccupy}")
        print(f"Door No           : {self.door}")
        print(f"Town                : {self.town}")
        print(f"Pincode            : {self.pin}")
        
s=student()
s.getdata()
s.show()

10. Create Student Class with Constructor and Destructor
#Code :

class student:
    def __init__(self):
        self.name=input("Enter the Name : ").capitalize()
        self.cls=input("Enter the Class (Roman) : ").upper()
        self.fn=input("Enter the Father's Name : ").capitalize()
        self.mob=input("Enter Father's Mobile No : ")
        self.foccupy=input("Enter Father's Occupation : ").capitalize()
        self.door=input("Enter Door No : ")
        self.town=input("Enter Town : ").capitalize()
        self.pin=input("Enter the Pincode : ")

    def show(self):
        print("***********************************************")
        print("\tSTUDENT DETAILS")
        print("***********************************************")
        print(f"Name                : {self.name}")
        print(f"Class                 : {self.cls}")
        print(f"Father's Name : {self.fn}")
        print(f"Mobile              : {self.mob}")
        print(f"Occupation      : {self.foccupy}")
        print(f"Door No           : {self.door}")
        print(f"Town                : {self.town}")
        print(f"Pincode            : {self.pin}")

    def __del__(self):
        print("Objects are destoryed Successfully")
        
s=student()
s.show()
del s

11. Implement interface using class
#Code :

from abc import abstractmethod
class shapes:
    @abstractmethod
    def area(self):
        pass
    
    @abstractmethod
    def peri(self):
        pass
    
    def display(self,area,peri):
        print(f"Area : {area}")
        print(f"Perimeter : {peri : .2f}")

class circle(shapes):
    def getdata(self):
        self.r=int(input("Enter the Radius : "))
    def area(self):
        return 3.14*self.r*self.r
    def peri(self):
        return 2*3.14*self.r

class triangle(shapes):
    def getdata(self):
        self.h=int(input("Enter the Height : "))
        self.b=int(input("Enter the Breath : "))
        self.s1=int(input("Enter the Side 1 : "))
        self.s2=int(input("Enter the Side 2 : "))
    def area(self):
        return 0.5*self.h*self.b
    def peri(self):
        return self.s1+self.s2+self.b

class square(shapes):
    def getdata(self):
        self.a=int(input("Enter the Side : "))
    def area(self):
        return self.a*self.a
    def peri(self):
        return 4*self.a

class rectangle(shapes):
    def getdata(self):
        self.h=int(input("Enter the Height : "))
        self.b=int(input("Enter the Breath : "))
    def area(self):
        return self.b*self.h
    def peri(self):
        return (2*self.b)*(2*self.h)
    
#Main Code
c=circle()
t=triangle()
s=square()
r=rectangle()
for o in c,t,s,r:
    name=type(o).__name__.upper()
    print(name)
    print("************************************")
    o.getdata()
    o.display(o.area(),o.peri())
    print("************************************")

12. program to inheritance with two child (derived) classes in Python
#Code :

from abc import abstractmethod
class s3d:
    @abstractmethod
    def area(self,n):
        pass
    def show(self,area):
        print(f"Area : {area}")

class cube(s3d):
    def area(self,n):
        return 6*n*n

class sphere(s3d):
    def area(self,n):
        return 4*3.14*n*n

s=sphere()
c=cube()
n=int(input("Enter the Radius : "))
for i in s,c:
    print(type(i).__name__)
    i.show(i.area(n))

13. Multiple inheritance in python
#Code :

class student:
    def getdata(self):
        self.name=input("Enter the Name : ").capitalize()
        self.cls=input("Enter the Class (Roman) : ").upper()
        self.rno=input("Enter the Roll No : ")
        self.fn=input("Enter the Father's Name : ").capitalize()
        self.mob=input("Enter Father's Mobile No : ")
        self.foccupy=input("Enter Father's Occupation : ").capitalize()
        self.door=input("Enter Door No : ")
        self.town=input("Enter Town : ").capitalize()
        self.pin=input("Enter the Pincode : ")

class marks:
    def mark(self):
        self.m=[]
        self.tot,self.avg=0,0
        print("Enter the Marks :")
        for i in range(5):
            temp=int(input(""))
            self.m.append(temp)
            self.tot+=temp
        for i in self.m:
            if i<35:
                self.res="Fail"
                break
            else:
                self.res="Pass"
        self.avg=self.tot/5

class result(student,marks):
    def show(self):
        print("***********************************************")
        print("\tSTUDENT DETAILS")
        print("***********************************************")
        print("PERSONAL DETAILS")
        print(f"Name                : {self.name}")
        print(f"Class                 : {self.cls}")
        print(f"Roll No             : {self.rno}")
        print(f"Father's Name : {self.fn}")
        print(f"Mobile              : {self.mob}")
        print(f"Occupation      : {self.foccupy}")
        print(f"Door No           : {self.door}")
        print(f"Town                : {self.town}")
        print(f"Pincode            : {self.pin}")
        print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
        print("MARK DETAILS")
        print("Subject Marks :")
        for i in self.m:
            print(i)
        print(f"Total                 : {self.tot}")
        print(f"Average            : {self.avg}")
        print(f"Result               : {self.res}")

s=result()
s.getdata()
s.mark()
s.show()

14. python program to check prime number using object oriented approach
#Code :

class Prime:
    def find_prime(self,n):
        prime_no=[]
        if n<2:
            print("Prime Number doesn't exist")
        for num in range(2,n+1):
            is_prime="True"
            for i in range(2,int(num/2)+1):  
                if num%i==0:
                    is_prime="False"
                    break
            if is_prime=="True":
                prime_no.append(num)
        return prime_no

p=Prime()
n=int(input("Enter the Range : "))
num=p.find_prime(n)
print(f"Prime Number in the Range {n} are,")
for i in num:
    print(i)

15. python program to count number of objects created
#Code :

class base:
    count=0
    def __init__(self):
        base.count+=1
o1=base()
o2=base()
o3=base()
print(f"No.of.Objects of the Class : {base.count}")

16. python program to Multilevel inheritance
#Code :

class student:
    def getdata(self):
        self.name=input("Enter the Name : ").capitalize()
        self.cls=input("Enter the Class (Roman) : ").upper()
        self.rno=input("Enter the Roll No : ")
        self.fn=input("Enter the Father's Name : ").capitalize()
        self.mob=input("Enter Father's Mobile No : ")
        self.foccupy=input("Enter Father's Occupation : ").capitalize()
        self.door=input("Enter Door No : ")
        self.town=input("Enter Town : ").capitalize()
        self.pin=input("Enter the Pincode : ")

class marks(student):
    def mark(self):
        self.m=[]
        self.tot,self.avg=0,0
        print("Enter the Marks :")
        for i in range(5):
            temp=int(input(""))
            self.m.append(temp)
            self.tot+=temp
        for i in self.m:
            if i<35:
                self.res="Fail"
                break
            else:
                self.res="Pass"
        self.avg=self.tot/5

class result(marks):
    def show(self):
        print("***********************************************")
        print("\tSTUDENT DETAILS")
        print("***********************************************")
        print("PERSONAL DETAILS")
        print(f"Name                : {self.name}")
        print(f"Class                 : {self.cls}")
        print(f"Roll No             : {self.rno}")
        print(f"Father's Name : {self.fn}")
        print(f"Mobile              : {self.mob}")
        print(f"Occupation      : {self.foccupy}")
        print(f"Door No           : {self.door}")
        print(f"Town                : {self.town}")
        print(f"Pincode            : {self.pin}")
        print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
        print("MARK DETAILS")
        print("Subject Marks :")
        for i in self.m:
            print(i)
        print(f"Total                 : {self.tot}")
        print(f"Average            : {self.avg}")
        print(f"Result               : {self.res}")

s=result()
s.getdata()
s.mark()
s.show()

17. Student height record program for a school in Python
#Code :

class student:
    def height(self):
        self.name=input("Enter the Name : ").capitalize()
        self.cls=input("Enter the Class (Roman) : ").upper()
        self.rno=input("Enter the Roll No : ")
        self.weight=int(input("Enter the Weight (kg): "))
        self.h=int(input("Enter the Height (cm) : "))

    def show(self):
        print("***********************************************")
        print("\tSTUDENT DETAILS")
        print("***********************************************")
        print(f"Name            : {self.name}")
        print(f"Class              : {self.cls}")
        print(f"Roll No          : {self.rno}")
        print(f"Weight (KG) : {self.weight}")
        print(f"Height (CM) : {self.h}")

s=student()
s.height()
s.show()

18. python program to manage a phone store (mobile shop) record using class
#Code :

class mobile:
    def __init__(self):
        self.m,self.mod=[],[]
        self.mob={
            "REDMI" : {
                "9A" : {
                    "PRICE" : 12500,
                    "STOCK" : 4
                    },
                "9PRIME" : {
                    "PRICE" : 11000,
                    "STOCK" : 3
                    },
                "13" : {
                    "PRICE" : 14000,
                    "STOCK" : 5
                    }
                },
            "SAMSUNG" : {
                "M01" : {
                    "PRICE" : 9500,
                    "STOCK" : 3
                    },
                "M31" : {
                    "PRICE" : 14000,
                    "STOCK" : 7
                    },
                "M02" : {
                    "PRICE" : 8500,
                    "STOCK" : 5
                    }
                },
            "IPHONE" : {
                "11" : {
                    "PRICE" : 44000,
                    "STOCK" : 5
                    },
                "12" : {
                    "PRICE" : 49999,
                    "STOCK" : 6
                    },
                "15" : {
                    "PRICE" : 69499,
                    "STOCK" : 2
                    }
                }
            }

    def sales(self):
        print("\tOUR MOBILE STOCKS")
        for i in self.mob.keys():
            print(i)
        self.mobile=input("Enter the Mobile : ").upper()
        for i in self.mob[self.mobile].keys():
            print(i)
        self.model=input("Enter the Mobile Model : ").upper()
        
        for i in self.mob[self.mobile][self.model]:
            print(f"{i} : {self.mob[self.mobile][self.model][i]}")
        d=input("Do the customer wanna buy this : Y/N ? : ").lower()
        if d=='y':
            self.m.append(self.mobile)
            self.mod.append(self.model)
            self.mob[self.mobile][self.model]["STOCK"]=self.mob[self.mobile][self.model]["STOCK"]-1

    def billing(self,name):
        tot=0
        if len(self.mod)==0:
            print("Empty bill appeared")
            break
        else:
            print("***********************************************")
            print("\tRAHUL MOBILE WORLD")
            print("***********************************************")
            print(f"Customer : {name}")
            print("***********************************************")
            print("Mobile\tModel\tPrice")
            for i in self.mod:
                t=self.mod.index(i)
                print(f"{self.m[t]}\t{i}\t{self.mob[self.m[t]][i]["PRICE"]}")
            tot+=self.mob[self.m[t]][i]["PRICE"]
            print("------------------------------------------------------------")
            print(f"\tTotal : {tot}")
            print("***********************************************")
            print("\t*THANK YOU VISIT AGAIN*")
        

m=mobile()
print("*********************************************************")
print("\tWELCOME TO RAHUL MOBILE WORLD")
print("*********************************************************")
try:
    while True:
        c=int(input("\n\t*MENU*\n1.MOBILES\n2.BILLING\n3.EXIT\nEnter Your Choice : "))
        match c:
            case 1:
                m.sales()
            case 2:
                name=input("Enter the Customer Name : ").upper()
                aadhar=int(input("Enter the Aadhar Number : "))
                m.billing(name)
            case 3:
                exit(0)
                print("***********************************************")
                print("\t*THANK YOU VISIT AGAIN*")
            case _:
                print("\tPLEASE MAKE VALID CHOICES")
                
except:
    print("\tERROR OCCURRED : PLEASE CHECK YOUR CHOICE")

19. python program to find the elder person of two persons using class & object
#Code :

class person:
    def age(self):
        self.dob_yr=int(input("Enter Your DOB Year : "))
        return self.dob_yr
    def elder(self,m,n):
        if m<n:
            return "Person 1 is the Elder One"
        else:
            return "Person 2 is the Elder One"

print("*ELDER ONE FINDER*")
p=person()
p1=person()
p2=person()
print(p.elder(p1.age(),p2.age()))

20. python program to bank management system
#Code :

from datetime import date
import random as r

class bank:
    
    def __init__(self):
        self.ac=r.sample(range(10000000,100000000), 1)
        self.ifsc="MIB02580"
        self.branch="Udumalpet"
        self.balance=0
        self.add=""
        self.trans={ "Deposit" : 0,"Withdraw" : 0}
        self.t1,self.t2=[],[]
    
    def customer(self):
        print("****************************************")
        print("\tCUSTOMER ACCOUNT")
        print("****************************************")
        self.name=input("Enter the Customer Name : ").upper()
        self.occup=input("Enter the Occupation : ").capitalize()
        self.dob=date.fromisoformat(input("Enter the DOB [yyyy-mm-dd] : "))
        temp=input("Enter the Address : ").strip().split(',')
        for i in temp:
            self.add=self.add+"\n"+i
        
    def deposit(self):
        print("****************************************")
        print("\tDEPOSITION PROCESS")
        print("****************************************")
        t=int(input("Enter the Deposit Amount : "))
        self.balance+=t
        self.t1.append(t)
        self.trans["Deposit"]=self.t1

    def withdraw(self):
        print("****************************************")
        print("\tWITHDRAWAL PROCESS")
        print("****************************************")
        t=int(input("Enter the Withdrawal Amount : "))
        if t>self.balance:
            print("\t**INSUFFICIENT BALANCE")
        else:
            self.balance-=t
            self.t2.append(t)
            self.trans["Withdraw"]=self.t2

    def transaction(self):
        print("****************************************")
        print("\tTRANSACTION HISTORY")
        print("****************************************")
        ch=input("Which details you want to know ? Deposit/Withdraw : ").capitalize()
        if self.trans[ch]!=0:
            print(f"Your {ch} History")
            print("---------------------------")
            for i in self.trans[ch]:
                print(i)
        else:
            print(f"{ch} history is empty ")

    def account(self):
        print("****************************************")
        print("\tACCOUNT DETAILS")
        print("****************************************")
        print(f"A/C No           : {self.ac}")
        print(f"Holder Name : {self.name}")
        print(f"DOB                : {self.dob}")
        print(f"Address          : {self.add}")
        print(f"Occupation    : {self.occup}")
        print(f"IFSC Code      : {self.ifsc}")
        print(f"Branch           : {self.branch}")
        print(f"Balance          : {self.balance}")
        print(f"Card               : {self.card}")

    def card(self):
        print("****************************************")
        print("\tATM CARD APPLICATION")
        print("****************************************")
        card_type=input("Enter the card type : Credit | Debit ?\n").capitalize()
        if card_type=="Credit":
            print("Credit Card Details")
            print("Card Charges : 350")
            print("Intrest : 5%")
            ch=input("Do you want to apply ? : Y/N\n").upper()
            if ch=='Y':
                self.balance-=350
                self.card=card_type
                print("\t*Credit card applied successfully*")
            else:
                print("\t*Application process unsuccessful*")
        else:
            print("Debit Card Details")
            print("Card Charges : 150")
            ch=input("Do you want to apply ? : Y/N\n").upper()
            if ch=='Y':
                self.balance-=150
                self.card=card_type
                print("\t*Debit card applied successfully*")
            else:
                print("\t*Application process unsuccessful*")

c1=bank()
print("****************************************")
print("\tMAARIYAMMAN INDIAN BANK")
print("****************************************")
print("Welcomes You !\n")
while True:
    print("****************************************")
    c=int(input("\t*MENU*\n1.NEW ACCOUNT\n2.DEPOSIT\n3.WITHDRAW\n4.TRANSACTION\n5.YOUR ACCOUNT\n6.ATM CARD\n7.EXIT\nEnter your choice : "))
    match c:
        case 1:
            c1.customer()
        case 2:
            c1.deposit()
        case 3:
            c1.withdraw()
        case 4:
            c1.transaction()
        case 5:
            c1.account()
        case 6:
            c1.card()
        case 7:
            exit(0)
            print("\tTHANK YOU")
        case _:
            print("INVALID OPTION : TRY AGAIN")


USD TO INR C++ PROGRAMMING

  NALLAMUTHU GOUNDER MAHALINGAM COLLEGE                                                 POLLACHI-642001                                     ...