You are on page 1of 3

FYBCA

SEMESTER – II
BCA1211C08 : Object Oriented Programming Date : 13/01/2023

1. Create a Country class with data members name and population and define setter and
getter methods for defining them.
2. Create a Product class with data members prod_name and price , along with a
parameterized constructor of prod_name and price, also create a list of products by
taking input from the user.
3. Create a Movie class as under and note the output

class Movie:
def __init__(self,a,b,c):
self.title=a
self.hero=b
self.heroine=c
def info(self):
print(‘Movie name:’,self.title)
print(‘Hero name:’,self.hero)
print(‘Heroine name:’,self.heroine)
list_of_movies=[]
while True:
title=input(‘Enter movie name:’)
hero=input(‘Enter hero name:’)
heroine=input(‘Enter heroine name:’)
m=Movie(title,hero,heroine)
list_of_movies.append(m)
print(‘Movie added successfully’)
option=input(‘Do you want to add one more movie[Yes/No]:’)
if option.lower()==’no’:
break
print(‘All movies information:’)
for movie in list_of_movies:
movie.info()
print()

4. Write a Python program to create a Department class.

a. Declare instance variable named dept_no inside constructor.


b. Declare instance variable named dept_name inside instance method.
c. Print all instance variables using __dict__.
d. Print all the instance variable values using print().
e. Create one instance method display() to print department info
f. Create one method delete_variable() to delete one instance variable
dept_name and delete it.
g. Delete dept_no from outside of the class.
h. Again print all the instance variable using __dict__.
i. Add three constructor in the class.Try to call each constructor by creating three
different object references. Check which constructor will be called.

5. Write a Python program to create a Test class


class Test:
def __init__(self):
self.a=10
self.b=20
self.c=30
self.d=40
def m1(self):
del self.d

a. Create an object reference of this class.


b. Print all instance variables.
c. Call m1 method and then print all instance variables.
d. Delete c instance variable from outside of the class and print all instance
variables.
e. Print all instance variables using __dict__.

6. Write a Python program to create a Test Class

class Test:
def __init__(self):
self.a=10
self.b=20
self.c=30
self.d=40

a. Create two object reference variables t1 and t2 of this class.


b. Delete a from t1 object reference.
c. Print all instance variable of t1 and t2 object reference. Note down the changes.[The
instance variables which are deleted from one object,will not be deleted from
other objects. ]
7. Write a Python program to create a Test Class
class Test:
def __init__(self):
self.a=10
self.b=20
a. Create two object reference variables t1 and t2 of this class.
b. Update value of a and b using t1 object reference.
c. Print all instance variable of t1 and t2 object reference. Note down the changes[If we
change the values of instance variables of one object then those changes won't
be reflected to the remaining objects ]
d. Using id() function check the addresses of self,t1 and t2 object references and
compare whether they are same or not.
8. Create a Student class having a parameterized constructor of name and marks.Also
define a method display() to print name and marks of Student object.Define one
more method grade() to check the class of student(1 st,2nd,3rd or Fail). Take input
from the user ,Number of students and take input from the user accordingly.

You might also like