Как рассчитать стоимость акций с помощью функции в Python - PullRequest
0 голосов
/ 24 мая 2019

Итак, я попытался запустить свой код так далеко, и он продолжает выдавать мне ошибку.Мне нужно рассчитать общую стоимость акций, но я застрял и очень запутался в том, как двигаться вперед.

#a list of items in a cafe
cafeMenu = ["coffee, muffins, cake, tea"]

#a dictionary with integer keys
intKeys_stockDict = {coffee: '12'
                     muffins: '9'
                     cake: '10'
                     tea: '8'
                     }


#a dictionary with  keys
int_ Keys_priceDict = {coffee: '15'
                       muffins: '12'
                       cake: '11'
                       tea: '10'
                       }


def totalstock(stockworth):

1 Ответ

0 голосов
/ 24 мая 2019
#a list of items in a cafe
cafeMenu = ["coffee", "muffins", "cake", "tea"]

intKeys_stockDict = {"coffee": 12,
                     "muffins": 9,
                     "cake": 10,
                     "tea": 8
                     }
int_Keys_priceDict = {"coffee": 15,
                       "muffins": 12,
                       "cake": 11,
                       "tea": 10
                       }

totalstock = 0
for item in cafeMenu:
  totalstock += intKeys_stockDict[item]*int_Keys_priceDict[item]
print(totalstock)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...