Informatics2-2018/Lab04

A MathWikiből
A lap korábbi változatát látod, amilyen Gaebor (vitalap | szerkesztései) 2018. március 8., 09:19-kor történt szerkesztése után volt.

previous up next

Tartalomjegyzék

Dictionaries

Exercises

Shopping

Let's say that you went to shopping and you have a python dictionary of the purchased goods. The keys are the items you bought and the values are the amount you bought.

purchased = { 
'banana': 0.6, 
'apple': 1.5, 
'pineapple': 2 }

And you also have the prices of the goods where the keys are the items in the store and the values are their unit price

arak = { 
'alma': 150, 
'szilva': 190, 
'ananász': 450, 
'banán': 300} 

A függvény adja meg hogy mennyit kell fizetnünk ezért a bevásárlásért (mennyi a kosarunk ára).

Feltételezhetjük hogy olyan dolog nincs a kosarunkban, ami nincs a bolt készletében (a mennyiségek kulcsai mind benne vannak az árak szótárban).

Cloudcoder

previous up next

Személyes eszközök