The Starbuzz code

The attachment from Starbuzz was a file called starbuzz .py. When you open it, you see this:

# Official Starbuzz Discount Module

# Copyright(c) Starbuzz Corporation

# All Rights Reserved.

# This function calculates a 5% discount on a price def discount(price):

return 0.95 * price

Lines that start with # are Comments; Python-will ignore them.

disdount f undtion, as provided by StavbiAz-

The first few lines begin with # characters; these are comments. Comments are just notes added by a programmer that are intended to be read by other programmers. Python will ignore them, because comments are not code.

After the comments comes the Starbuzz discount () function. It's just like the discount function you wrote, except instead of returning a 10% discount, it returns a 5% discount.

disdount f undtion, as provided by StavbiAz-

' This function returns a pride that's 5% lower than the pride rt was given.

Your code will have to use both discounts:

It will apply a 10% discount to everything.

And if somebody presents a Starbuzz Discount Card, it will also have to apply the 5% Starbuzz discount.

You need to change the code so that it uses both of the discount () functions. Can you see a problem? What is it?

identity confusion

Was this article helpful?

0 0

Post a comment