Informatics2-2018/Lab04
A MathWikiből
(Változatok közti eltérés)
1. sor: | 1. sor: | ||
+ | [[Informatics2-2018/Lab03|previous]] [[Informatics2-2018#Labs|up]] [[Informatics2-2018/Lab05|next]] | ||
+ | |||
= Dictionaries = | = Dictionaries = | ||
− | |||
== Exercises == | == Exercises == | ||
6. sor: | 7. sor: | ||
=== Shopping === | === 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 = { | arak = { | ||
14. sor: | 22. sor: | ||
'ananász': 450, | 'ananász': 450, | ||
'banán': 300} | '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). | 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). | 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 == | ||
+ | * | ||
+ | [[Informatics2-2018/Lab03|previous]] [[Informatics2-2018#Labs|up]] [[Informatics2-2018/Lab05|next]] |
A lap 2018. március 8., 10:19-kori változata
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).