sergeekСделал так. Выдает ошибку.
enter a number or Enter to finsh:8 enter a number or Enter to finsh:5 enter a number or Enter to finsh:6 enter a number or Enter to finsh:455 enter a number or Enter to finsh:454 enter a number or Enter to finsh:7 enter a number or Enter to finsh:9 enter a number or Enter to finsh:3 enter a number or Enter to finsh:2 enter a number or Enter to finsh:4 enter a number or Enter to finsh:6886 enter a number or Enter to finsh:55 enter a number or Enter to finsh:46 enter a number or Enter to finsh:46 enter a number or Enter to finsh:6 enter a number or Enter to finsh:46 enter a number or Enter to finsh: List = [8, 5, 6, 455, 454, 7, 9, 3, 2, 4, 6886, 55, 46, 46, 6, 46] count = 16 Total = 8038 Seredne = 502.375 Min = 2 Max = 6886 [2, 3, 4, 5, 6, 6, 7, 8, 9, 46, 46, 46, 55, 454, 455, 6886] Traceback (most recent call last): File "sum1.py", line 45, in <module> List_2=med(List) File "sum1.py", line 42, in med return (max(lst[:hf]) + min(lst[hf:])) / 2 TypeError: 'int' object is not callable ***Repl Closed***
Вот код:
count=0 List=[] total=0 while True: a= input("enter a number or Enter to finsh:") if a: try: number=int(a) except ValueError as err: print(err) continue total+=number count+=1 list.append(List,number) Li=len(List) else: break i=0 min=List[i] max=List[i] while i<len(List): if List[i]<min: min=List[i] if List[i]>max: max=List[i] i+=1 if count: print("List = ",List) print("count = ",count,"Total = ",total,"Seredne = ", total/count, "Min = ", min, "Max = ", max) for I in range(count): idxMin=I for J in range(I+1,count): if List[J]<List[idxMin]: idxMin=J temp=List[idxMin] List[idxMin]=List[I] List[I]=temp print(List) def med(lst): hf = len(lst) // 2 if hf*2 == len(lst): return (max(lst[:hf]) + min(lst[hf:])) / 2 else: return lst[hf] List_2=med(List) print(List_2)

Как всегда предложу короткий вариант в котором как и просит автор нет деления по модулю.