Informatics2-2018/Lab04

A MathWikiből
(Változatok közti eltérés)
(Új oldal, tartalma: „= Dictionaries = előző fel következő == Exercises == === Shopping ===…”)
 
 
(egy szerkesztő egy közbeeső változata nincs mutatva)
1. sor: 1. sor:
 +
[[Informatics2-2018/Lab03|previous]] [[Informatics2-2018#Labs|up]] [[Informatics2-2018/Lab05|next]]
 +
 
= Dictionaries =
 
= Dictionaries =
[[Informatics2-2018/Lab03|előző]] [[Informatika2-2018#Gyakorlat|fel]] [[Informatika2-2018/Gyakorlat5|következő]]
 
  
 
== Exercises ==
 
== Exercises ==
6. sor: 7. sor:
 
=== Shopping ===
 
=== Shopping ===
  
A feladat a már előadáson látott feladat egy változata.
+
Let's say that you went to shopping and you have a python dictionary of the purchased goods.
Írjunk olyan függvényt, melynek két bemenete két szótár. Az első az árak szótár, mely a boltban található összes áruhoz hozzárendeli annak árát. A másik a mennyiségek szótár, mely kulcsként tartalmazza, hogy mit vettünk értékként, pedig hogy mennyit vettünk az adott termékből. Pl:
+
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 = {  
+
  prices = {  
  'alma': 150,  
+
  'apple': 150,  
  'szilva': 190,  
+
  'plum': 190,  
  'ananász': 450,  
+
  'pineapple': 450,  
  'banán': 300}  
+
  'banana': 300}  
  
mennyisegek = {
+
The function should return the total cost of our shopping: unit price times amount summed for the purchased goods.
'banán': 0.6,
+
'alma': 1.5,
+
'ananász': 2 }
+
  
A függvény adja meg hogy mennyit kell fizetnünk ezért a bevásárlásért (mennyi a kosarunk ára).
+
== Cloudcoder ==
 +
* '''grader'''
 +
* '''topgrades'''
 +
* '''soccergoal'''
 +
* '''enciclopedia'''
 +
* '''storeupdate'''
  
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).
+
[[Informatics2-2018/Lab03|previous]] [[Informatics2-2018#Labs|up]] [[Informatics2-2018/Lab05|next]]

A lap jelenlegi, 2018. március 8., 12:56-kori változata

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

prices = { 
'apple': 150, 
'plum': 190, 
'pineapple': 450, 
'banana': 300} 

The function should return the total cost of our shopping: unit price times amount summed for the purchased goods.

Cloudcoder

  • grader
  • topgrades
  • soccergoal
  • enciclopedia
  • storeupdate

previous up next

Személyes eszközök