Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
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
7 Respostas
+ 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))
+ 1
ŠŠ»ŠµŠŗŃŠ°Š½Š“Ń but in according to practice we have to remove only one max value.
+ 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
0
Because 1024 are meets 2 times in data
0
Does not matter, it prints 1782.3200000000002 :(
0
Ok, thanks!
0
Try printing sum(data) after removing the max value