0

Help pls

data = [7, 5, 6.9, 1, 8, 42, 33, 128, 1024, 2, 8, 11, 0.4, 1024, 66, 809, 11, 8.9, 1.1, 3.42, 9, 100, 444, 78] #ваш код data.remove (max(data)) data.remove (max(data)) data.remove (min(data)) res=0 for i in data: res+=i continue print (res) It prints 1782,320000002 , need 1782,32

25th Jun 2021, 8:28 AM
Александр
7 Answers
+ 3
Александр Why did you removed max value two times? Remove only once and also no need to use loop also using of continue doesn't make sense. continue use to skip current iteration on condition basis. So do this: data.remove(max(data)) data.remove(min(data)) print (sum(data))
25th Jun 2021, 8:48 AM
A͢J
A͢J - avatar
+ 1
Александр but in according to practice we have to remove only one max value.
25th Jun 2021, 9:15 AM
A͢J
A͢J - avatar
+ 1
Use print(round(res, 2)) This will print 1782.32 instead of 1782.320000002 round(x, n) converts value of x upto n digit after decimal points
27th Jun 2021, 4:00 AM
DHANANJAY PATEL
DHANANJAY PATEL - avatar
0
Because 1024 are meets 2 times in data
25th Jun 2021, 9:08 AM
Александр
0
Does not matter, it prints 1782.3200000000002 :(
25th Jun 2021, 9:10 AM
Александр
0
Ok, thanks!
25th Jun 2021, 9:50 AM
Александр
0
Try printing sum(data) after removing the max value
26th Jun 2021, 11:59 AM
Aathi Sankar