Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Greetings I need to get this output Total price for one book: 17.97 Total price for two books: 33.69 Total price for 60 books: 945.45

Greetings

I need to get this output

Total price for one book: 17.97 Total price for two books: 33.69 Total price for 60 books: 945.45 Total price for zero books: 0

but note that you need to use some form of branching condition to get the last case to work.

My code so far.... I get the 1 book and the zero, but not the two or 60.

def total_price(n): book_price = 24.95 discount = 0.60 shipping_price_many = 0.75 shipping_price = 3.00

if n == 0: return 0

total_price = book_price * discount + shipping_price return total_price

print("Total price for one book:", total_price(1)) print("Total price for two books:", total_price(2)) print("Total price for 60 books:", total_price(60)) print("Total price for zero books:", total_price(0))

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

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions