Question

python Question. test_result = [12426, 10701, 8291, 6784, 5433, 5956, 6805, 6433, 6950, 10174, 12268, 14677,...

python Question.

test_result = [12426, 10701, 8291, 6784, 5433, 5956, 6805, 6433, 6950, 10174, 12268, 14677, 10552, 14296, 17306, 15438, 17913, 18735, 20310, 20519, 21096, 16770, 17186, 10001, 17949, 20333, 18770, 17637, 15196, 16477, 15718, 14734, 14479, 11975, 9528, 10702, 9966, 8181, 9310, 9243, 8705, 8379, 7829, 8664, 8259, 9357, 8115, 8841, 9060, 10901, 10965, 13942, 15487, 14169, 18165, 18258, 8039, 19248, 19263, 18120, 17728, 18627, 19744, 19094, 19109, 18296, 18108, 7091, 17352, 17215, 14699, 12495, 10194, 8513, 8762, 8308, 7652, 7046, 5199, 6874, 7765, 7018, 7395, 6484, 7664, 7123, 10065, 12526, 12376, 5526, 14652, 14213, 14473, 13919, 16774, 15793, 16222, 16916, 14588, 13499, 6607, 13523, 11921, 9551, 7849, 6165, 5606, 4832, 5279, 5429, 5165, 12956, 7481, 4902, 4139, 3787, 4037, 5221, 4983, 3724, 3752, 5978, 3809, 7331, 6970, 7288, 6545, 7803, 7860, 8517, 9006, 10180, 10267, 9977, 9211, 10384, 10388, 11845, 11533, 11052, 10524, 10053, 9084, 8685, 7558, 9004, 7353, 7331, 6554, 4588, 4036, 2617, 2862, 2775, 2798, 2452, 9527, 5504, 6591, 7849, 10066, 9188, 5932, 5105, 7569, 8873, 10223, 10164, 10732, 11413, 10523, 11459, 13147, 11565, 10361, 7937, 9336, 7490, 11064, 9304, 6436, 5900, 4639, 3808, 3843, 3720, 3887, 4735, 4544, 12209, 4836, 4834, 4855, 4492, 6118, 7267, 8444, 7680, 9972, 12136, 10968, 13835, 13661, 16700, 16662, 17301, 18723, 19612, 16915, 16786, 17727, 10494, 15631, 13786, 12734, 12964, 13139, 10495, 10103, 7779, 7331, 8122, 11622, 10955, 7819, 6181, 4999, 5258, 5414, 5902, 6213, 6786, 7879, 9457, 10850, 10615, 13362, 15357, 14585, 16033, 15174, 16374, 14527, 17103, 15739, 11402, 16873, 17957, 14567, 14740, 12750, 13970, 11356, 8612, 6742, 6752, 10678, 6039, 5716, 4877, 3996, 4860, 5780, 5748, 5520, 4831, 4403, 10480, 5603, 8477, 10954, 14647, 16790, 17681, 18709, 19004, 20670, 18890, 10074, 20217, 16563, 18827, 16455, 17265, 15489, 14857, 14365, 11791, 10087, 9330, 9073, 9268, 8341, 7813, 6290, 6428, 6012, 6147, 5380, 5544, 8509, 5877, 7872, 8603, 9460, 10647, 12277, 13080, 14712, 12539, 12387, 7092, 12185, 13810, 11976, 11952, 12875, 11712, 13573, 14516, 15993, 12460, 8251, 8390, 7400, 6809, 5685, 4958, 4933, 5437, 4955, 5390, 3957, 11217, 11143, 5691, 5511, 6236, 6045, 6224, 6064, 5917, 7650, 9892, 11603, 11967, 12636, 13632, 16461, 19625, 16959, 18335, 15950, 16367, 17543, 15724, 13178, 18128, 15827, 15456, 13066, 11761, 10252, 8079, 14367, 14069, 13366, 13783, 13261, 13330, 13469, 9009, 13325, 12480, 10340, 8828, 7949, 6990, 4717, 5990, 6262, 7454, 11805, 9599, 7889, 9041, 9360, 9245, 9141, 11384, 9253, 10518, 7880, 10089, 10243, 10927, 10801, 8258, 8083, 12113, 16070, 17306, 18609, 16113, 11856, 20715, 18528, 19592, 17620, 15958, 14664, 17458, 14570, 15649, 10417, 9741, 9823, 8168, 5762, 5196, 4686, 5490, 5511, 6896, 6565, 8179]

I want to multiply every number by 2.765. How to do that?

my try:


File "<ipython-input-14-56bbffad5f3c>", line 1, in <module>
new_result = test_result * 2.675

TypeError: can't multiply sequence by non-int of type 'float'

what is the right answer?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import math

test_result = [12426, 10701, 8291, 6784, 5433, 5956, 6805, 6433, 6950, 10174, 12268, 14677, 10552, 14296, 17306, 15438, 17913, 18735, 20310, 20519,

               21096, 16770, 17186, 10001, 17949, 20333, 18770, 17637, 15196, 16477, 15718, 14734, 14479, 11975, 9528, 10702, 9966,

               8181, 9310, 9243, 8705, 8379, 7829, 8664, 8259, 9357, 8115, 8841, 9060, 10901, 10965, 13942, 15487, 14169, 18165,

               18258, 8039, 19248, 19263, 18120, 17728, 18627, 19744, 19094, 19109, 18296, 18108, 7091, 17352, 17215, 14699, 12495,

               10194, 8513, 8762, 8308, 7652, 7046, 5199, 6874, 7765, 7018, 7395, 6484, 7664, 7123, 10065, 12526, 12376, 5526, 14652,

               14213, 14473, 13919, 16774, 15793, 16222, 16916, 14588, 13499, 6607, 13523, 11921, 9551, 7849, 6165, 5606, 4832, 5279,

               5429, 5165, 12956, 7481, 4902, 4139, 3787, 4037, 5221, 4983, 3724, 3752, 5978, 3809, 7331, 6970, 7288, 6545, 7803, 7860,

               8517, 9006, 10180, 10267, 9977, 9211, 10384, 10388, 11845, 11533, 11052, 10524, 10053, 9084, 8685, 7558, 9004, 7353, 7331,

               6554, 4588, 4036, 2617, 2862, 2775, 2798, 2452, 9527, 5504, 6591, 7849, 10066, 9188, 5932, 5105, 7569, 8873, 10223, 10164, 10732,

               11413, 10523, 11459, 13147, 11565, 10361, 7937, 9336, 7490, 11064, 9304, 6436, 5900, 4639, 3808, 3843, 3720, 3887, 4735, 4544, 12209,

               4836, 4834, 4855, 4492, 6118, 7267, 8444, 7680, 9972, 12136, 10968, 13835, 13661, 16700, 16662, 17301, 18723, 19612, 16915, 16786, 17727,

               10494, 15631, 13786, 12734, 12964, 13139, 10495, 10103, 7779, 7331, 8122, 11622, 10955, 7819, 6181, 4999, 5258, 5414, 5902, 6213, 6786,

               7879, 9457, 10850, 10615, 13362, 15357, 14585, 16033, 15174, 16374, 14527, 17103, 15739, 11402, 16873, 17957, 14567, 14740, 12750, 13970,

               11356, 8612, 6742, 6752, 10678, 6039, 5716, 4877, 3996, 4860, 5780, 5748, 5520, 4831, 4403, 10480, 5603, 8477, 10954, 14647, 16790, 17681,

                18709, 19004, 20670, 18890, 10074, 20217, 16563, 18827, 16455, 17265, 15489, 14857, 14365, 11791, 10087, 9330, 9073, 9268, 8341, 7813,

               6290, 6428, 6012, 6147, 5380, 5544, 8509, 5877, 7872, 8603, 9460, 10647, 12277, 13080, 14712, 12539, 12387, 7092, 12185, 13810, 11976,

               11952, 12875, 11712, 13573, 14516, 15993, 12460, 8251, 8390, 7400, 6809, 5685, 4958, 4933, 5437, 4955, 5390, 3957, 11217, 11143, 5691,

               5511, 6236, 6045, 6224, 6064, 5917, 7650, 9892, 11603, 11967, 12636, 13632, 16461, 19625, 16959, 18335, 15950, 16367, 17543, 15724, 13178,

               18128, 15827, 15456, 13066, 11761, 10252, 8079, 14367, 14069, 13366, 13783, 13261, 13330, 13469, 9009, 13325, 12480, 10340, 8828, 7949, 6990,

               4717, 5990, 6262, 7454, 11805, 9599, 7889, 9041, 9360, 9245, 9141, 11384, 9253, 10518, 7880, 10089, 10243, 10927, 10801, 8258, 8083, 12113,

               16070, 17306, 18609, 16113,

               11856, 20715, 18528, 19592, 17620, 15958, 14664, 17458, 14570, 15649, 10417, 9741, 9823, 8168, 5762, 5196, 4686, 5490, 5511, 6896, 6565, 8179]#this is the list

count=0# declare and initialize count=0

for i in test_result:#for all elements in list

    count=count+1# incerement count

    j=float(i*2.675)# calucate by multiplying and convert it to float

    if(count==20):#this is just for printing purpose

        print("\n")#new line

        print("%.2f" % round(j,2),end=" ")#"%.2f" prints up to 2 decimal places

        count=0#initialize count=0

    else:

        print("%.2f" % round(j,2),end=" ")#"%.2f" prints up to 2 decimal places

Add a comment
Know the answer?
Add Answer to:
python Question. test_result = [12426, 10701, 8291, 6784, 5433, 5956, 6805, 6433, 6950, 10174, 12268, 14677,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT