Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a definition for a class named Book with attributes title , price and author , where author is a Contact object and title is

Write a definition for a class named Book with attributes title, price and author, where author is a Contact object and title is a String, and price is a float number.

You also need to define the Contact class, which has attributes name and email, where name and email are both String.

Instantiate a couple of Book objects that represents books with title, price and author (You can come up with the attributes values for each object)

Write a function named print_book that takes an object of Book and prints out the value of its attributes. (Make the message friendly to read, for example "Book title: [sometitle]", "Book price: [$33.75]", etc

Write a function named which_is_more_expensive that takes two Book objects as parameters and returns the reference of the Book object with higher price

Write a function named which_is_more_expensive_by_copy that takes two Book objects as parameters and returns a copy of the Book object with higher price

Write a function named calculate_total_price that takes two Book objects as parameters and returns the total price of the two books

Make functions calls of all these functions by passing the Book objects you created.

[Check point] Submit your python code as .py file in text format, and capture the screens of your program running showing the input and output.

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

2. Outline the functions of nonverbal communication

Answered: 1 week ago