Answer the question
In order to leave comments, you need to log in
Yandex workshop 15. Relationship analysis between columns. How to decide?
Please help me decide:
data = [
['Grinning', 2.26, 1.02, 87.3],
['Shining with joy', 19.1, 1.69, 150.0],
['Rolling with laughter', 25.6, 0.774, 0.0],
['Tears joy', 233.0, 7.31, 2270.0],
['Wink', 15.2, 2.36, 264.0],
['Happy', 22.7, 4.26, 565.0],
['Heart eyes', 64.6, 11.2, 834.0],
[' Kisses', 87.5, 5.13, 432.0],
['Thoughtful', 6.81, 0.636, 0.0],
['Indifference', 6.0, 0.236, 478.0],
['Sunglasses', 4.72, 3.93, 198.0],
['Loud crying', 24.7, 1.35, 654.0],
['Kiss mark', 21.7, 2.87, 98.7],
['Two hearts', 10.0, 5.69, 445.0],
['Heart', 118.0, 26.0, 1080.0],
['Hearts', 3.31, 1.82, 697.0],
['Class', 23.1, 3.75, 227.0],
['Shrug', 1.74, 0.11, 0.0],
[ 'Fire', 4.5, 2.49, 150.0],
['Recycle', 0.0333, 0.056, 932.0]
]
print('Emoji Name | Twitter/Instagram Ratio')
print('------------ ------------------------------')
name = 0
ratio = 0
for row in data:
# save to "Emoji Name" variable (column 0)
name = data[0]
# save to "Twitter/Instagram Ratio" variable
# (column 3 to column 2)
ratio += data[3][2]
# output the string to screen
print('{: <16} | {: >29.2f}'.format(name, ratio))
Traceback (most recent call last):
File "main.py", line 43, in
print('{: <16 } |{: >29.2f}'.format(name, ratio))
TypeError: unsupported format string passed to list.__format__
Answer the question
In order to leave comments, you need to log in
for row in data:
# сохраните в переменную «Название эмодзи» (столбец 0)
name = data[0]
# сохраните в переменную «Соотношение Твиттер/Instagram»
# (столбец 3 к столбцу 2)
ratio += data[3][2]
it was necessary to divide the value of column 3 by the value of column 2, i.e. row[3]/row[2] . Hey! We have a whole service in the Workshop for answering such questions, you already write, okay? Do not be shy :) If something does not work out, we are always waiting for you here - https://yandex.ru/support/praktikum/feedback.html, we will be happy to help and figure it out together.
name = 0
ratio = 0
for row in data:
name = row[0]
ratio = row[3]/row[2]
print('{: <16} | {: >29.2f}'.format(name, ratio ))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question