Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Book class where

Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Book class where a book contains the following components (attributes): an author, a title, and number of pages. PLEASE DO NOT HARD CODE ANY CONSTANT VALUE IN THE SOURCE CODE: THIS MUST BE DONE WITH USER INPUT.

This class includes several methods: to change the values of these attributes, and to display their values. Separately, the main program must:

request the corresponding data from input and create a book object.

invoke a method to change the value of one of its attributes

invoke a method that displays the value of each attribute.

image text in transcribed

I've provided the code I have so far. I am stuck on the changing attribute method as I was trying to use validation to confirm if they wanted to change the title, author, or page numbers but don't know how to proceed.

-Book Book.py * ! *.- Book.py x Book ~/Py 1 Book.py 2 IlI External Lib3 class Book: #Book class def-init--(self): #Method creating the Book object with it's attributes self.title = "" self.author self.pages ". def get Information (self): #Method to display the value of each attribute info-"%s , by As has As pages." % (self.title, selfauthor, self.pages) return info def main(): book-1 = Book() #Main method requesting data from input book 1.title-raw input("What is the title of your book? ") book_ 1.author raw_input("Who is the author?") book_1.pages = raw..input ("How many pages are in your book? ") print book-1.getInformation() #Invoking method to display attributes 14 if -name-- "--main--": =: 17 main) 19 # def changeAttribute(): #method to change attributes #print ("Would you like to change an attribute? Answer True while Answer =wrcus ans input ("") =

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe what the Discount on Notes Payable represents.

Answered: 1 week ago

Question

Does it have correct contact information?

Answered: 1 week ago