0% found this document useful (0 votes)
25 views

Assignment 4

The document outlines assignments for an Object Oriented Programming class, including creating classes to: 1) Perform calculations like sum and factorial of integers. 2) Represent books with attributes like title, author, and price, including a constructor and display method. 3) Create and display multiplication tables. 4) Implement exponentiation. 5) Keep a record of books in a library using a menu-driven program and Book class.

Uploaded by

sourabh k
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Assignment 4

The document outlines assignments for an Object Oriented Programming class, including creating classes to: 1) Perform calculations like sum and factorial of integers. 2) Represent books with attributes like title, author, and price, including a constructor and display method. 3) Create and display multiplication tables. 4) Implement exponentiation. 5) Keep a record of books in a library using a menu-driven program and Book class.

Uploaded by

sourabh k
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

FYBCA

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

1.  Create a  Computation class  with a default constructor (without parameters)


allowing to perform various calculations on integer numbers.

2. Create a method called Sum() allowing to calculate the sum of the first n


integers 1 + 2 + 3 + .. + n. Test this method.

3.  Create a method called Factorial() which allows to calculate the factorial of


an integer. Test the method by instantiating the class.

4. Define a Book class with the following attributes: Title, Author (Full name),


Price.
i) Define a constructor used to initialize the attributes of the method
with values entered by the user.
ii) Set the View() method to display information for the current book.
iii) Write a program to testing the Book class.

5.  Create a tableMult() method which creates and displays the multiplication


table of a given integer. Then create an allTablesMult() method to display all
the integer multiplication tables 1, 2, 3, ..., 9.

6.  Write a Python class to implement pow(x, n). 


7. Write a menu-driven program that keeps record of books and journals
available in the library.
Class Book:
Def __init__(self):
Self.title=””
Self.author=””
Self.price=0
Def read(self):
Self.title=input(“Enter Book title:”)
Self.author=input(“Enter Book author:”)
Self.price=float(input(“Enter Book price:”))

Def display(self):

Print(“Title:”,self.title)

Print(“Author:”,self.author)

Print(“Price:”,self.price)

My_books=[]

Ch=’y’

While(ch==’y’):

Print(‘’’

1. Add New Books

2. Display Books

‘’’)

Choice=int(input(“Enter choice:”))

If(choice==1):

Book=Book()

Book.read()

My_books.append(book)

Elif(choice==2):

For I in my_books:

i.display()

else:
print(“Invalid choice”)

ch=input(“Do you want to continue:”)

print(“Thanks….Bye….”)

8. Write a program that swaps two members of a class.


9. Write a program that has a class Car.Create two objects and set car1 to be a
red convertible with price 10 lakh Rs and name Pugo,and car2 to be a blue
sedan named Mavo worth 6 lakh Rs.

You might also like