Exercise 4: Discount? Wow

In this exercise, you will be required to write a set function both with and without the set keyword.

Problem Statement

This exercise has two parts.

First Part

The shop has decided to offer a 10% discount on Cheese. In the first part, you are required to write a set function setPrice which updates the price after computing the discount.

Second Part

In the second part, you are required to implement the same functionality but this time you need to make the function using the set keyword instead. As an addition, you also need to call setPrice in the testFunc function given.

Note: We are only using the testFunc function for testing purposes, so there’s no need to worry. Just call your function there.

Sample Input

20

Sample Output

18

Note: The skeleton function for setPrice is given in both code tabs. Right now, it is not being passed any parameters. You need to pass it appropriate parameter/parameters, so use appropriate keywords and write the code for implementation as well.

Get hands-on with 1200+ tech skills courses.