Question: PART 1 : Working with dict Write code to do the following: 1 a . Copy the following class into lab 5 sol.py ` `

PART 1: Working with dict
Write code to do the following:
1a. Copy the following class into lab5sol.py
```
class Book:
def __init__(self, title, pubyr=2000, price=24.99):
self._title = title # title of book
self._pubyr = pubyr # publication year
self._price = price # price of book
def getTitle(self):
return self._title
def getPubyr(self):
return self._pubyr
def setPubyr(self, year):
self._pubyr = year
```
1b. Create 3 different instances (objects) bookl, book 2 and book 3 of class Book with suitable values for the parameters and put them in a list called booklist
1c. Write the str () method for Book class. This should output the title of the book and the year it was published. For example, The Hobbit published in 2000
\(1 d \).
- Write method called getPrice(self, price) for Book class. This method returns the price of the book.
- Write method called setPrice(self, price) for Book class. This method sets the price of the book.
1e. For each book in booklist, print the information for the book (using the str () method).
Sample output :
```
"C:\Program Files (x86)\Python312\pythd
******* OUTPUT FOR PART 1********
The Hobbit published in 2000
A Good Story published in 2022
Python Programming published in 2020
```
PART 1 : Working with dict Write code to do the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!