форкнуто от main/python-labs
Вы не можете выбрать более 25 тем
Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
26 строки
1.2 KiB
Python
26 строки
1.2 KiB
Python
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
|
|
Type "help", "copyright", "credits" or "license()" for more information.
|
|
>>> professions = {["Программист", 200000, 0.55, True], ["Учитель", 90000, 0.35, True], ["Врач", 110000, 0.25, True]}
|
|
Traceback (most recent call last):
|
|
File "<pyshell#0>", line 1, in <module>
|
|
professions = {["Программист", 200000, 0.55, True], ["Учитель", 90000, 0.35, True], ["Врач", 110000, 0.25, True]}
|
|
TypeError: unhashable type: 'list'
|
|
>>> professions = {"Программист": [200000, 0.55, True], "Учитель": [90000, 0.35, True], "Врач": [110000, 0.25, True]}
|
|
>>> professions
|
|
{'Программист': [200000, 0.55, True], 'Учитель': [90000, 0.35, True], 'Врач': [110000, 0.25, True]}
|
|
>>> profession = "Врач"
|
|
>>> characteristics = professions[profession]
|
|
>>> characteristics
|
|
[110000, 0.25, True]
|
|
>>>
|
|
>>> money = [profession[0] for profession in professions.values()]
|
|
>>> money
|
|
[200000, 90000, 110000]
|
|
>>>
|
|
>>> average = [profession[1] for profession in professions.values()]
|
|
>>> average
|
|
[0.55, 0.35, 0.25]
|
|
>>> average1 = sum(average)/len(average)
|
|
>>> average1
|
|
0.3833333333333333
|