Discounts X52808


Statement
 

pdf   zip   main.py

thehtml

Prices for some items on sale can be stored in a dictionary. Write a function discount that receives such a dictionary and modifies it in such a way that the prices have been discounted a 10%. The function must return the modified dictionary (remember: dict’s are mutable). Item names are arbitrary strings. Prices are in whole euros (namely int) both before and after the discount and, therefore, they must be rounded after applying the discount.

Observation

If you use doctests, remember to ensure that the Jutge submission does not run them.

Sample session
>>> discount({ 'Coke': 8, 'Red Bull': 11, 'Espresso': 3 })
{'Coke': 7, 'Red Bull': 10, 'Espresso': 3}
>>> discount({ 'Our unique product': 1000 })
{'Our unique product': 900}
>>> discount({})
{}
>>> discount({ 'A': 101, 'B': 103, 'C': 105, 'D': 107 })
{'A': 91, 'B': 93, 'C': 94, 'D': 96}
>>> discount( { 'Cloud Nine': 100 } ) == { 'Cloud Nine': 90 }
True
>>> d = { 'Cloud Nine': 100 }
>>> print(discount(d), d, sep = '\n')
{'Cloud Nine': 90}
{'Cloud Nine': 90}
>>> print(discount(d), d, sep = '\n')
{'Cloud Nine': 81}
{'Cloud Nine': 81}
Information
Author
Language
English
Official solutions
Python
User solutions
Python