- Www From Collections Import Counter Def Average Array Summ 0 For Number In Array Summ Summ Number Return Summ 1 (184.98 KiB) Viewed 12 times
www. from collections import Counter def average (array): summ= 0 for number in array: summ= summ + number return (summ/
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
www. from collections import Counter def average (array): summ= 0 for number in array: summ= summ + number return (summ/
www. from collections import Counter def average (array): summ= 0 for number in array: summ= summ + number return (summ//len(array)) def mode(array): n = len(array) x = Counter(array). mode= dict(x) 4pt2.py - /Users/ m = [k for k, v in mode.items() if v==max(list(x.values()))] if len(m): mode = "no mode" else: return mode mode = ', '.join(map(str,m)) def sorting (array): for number in range(len (array)): for j in range (number,len (array)): if(array [number] < array[j]): else: temp array [number] array [number] = array[j] array[j] temp return array def searching (array): p = int(input ("Enter a number to search for: ")) for number in array: if(number==p): print("The number you are looking for has been found"). break print("The number you are looking for was not found") def printing (array): print(" brary/Mobile Documents/com-apple-... print("The average is: ", average (array}) print("The mode is: ", mode(array)) ") print("The numbers from maximum to minimum is: ", sorting(array)) searching (array) array=list(map(int, input ("Enter a series of numbers: ").split())) printing (array) Ln: 13 Col: 0 >>> IDLE Shell 3.10.2 Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1 300.0.29.30)] on darwin Type "help", "copyright", "credits" or "license()" for more information. = RESTART: /Users/ tion/CS 305/ugh.py Enter a series of numbers: 3 4 4 6 7 'Library/Mobile Documents/com-apple-CloudDocs/Educa The average is: 4 The mode is: 4 The numbers from maximum to minimum is: [7, 6, 4, 4, 3] Enter a number to search for: 5. The number you are looking for was not found = RESTART: /Users/ tion/CS 305/ugh.py Enter a series of numbers: 5 9 8 7 3 'Library/Mobile Documents/com-apple-CloudDocs/Educa The average is: 6 The mode is no mode The numbers from maximum to minimum is: [9, 8, 7, 5, 31 Enter a number to search for: 81 The number you are looking for has been found Ln: 21 Col: 0