DOMMETI commited on
Commit
4cf2fc4
·
verified ·
1 Parent(s): c4d8a93

Update pages/Measurement_of_Central_Tendency.py

Browse files
pages/Measurement_of_Central_Tendency.py CHANGED
@@ -95,4 +95,35 @@ checking the frequency in list we come across a situtaion where we will find thr
95
  ''',unsafe_allow_html=True)
96
  st.markdown(''':violet[Multi_Mode] \n Let's understand why this situation raises for example let's take list of numbers [1,1,2,2,3,3,4,4,5]. here by
97
  checking the frequency in list we come across a situtaion where we will find more than three maximun frequecy repeated value hence the output will be Multi_Mode.
98
- ''',unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  ''',unsafe_allow_html=True)
96
  st.markdown(''':violet[Multi_Mode] \n Let's understand why this situation raises for example let's take list of numbers [1,1,2,2,3,3,4,4,5]. here by
97
  checking the frequency in list we come across a situtaion where we will find more than three maximun frequecy repeated value hence the output will be Multi_Mode.
98
+ ''',unsafe_allow_html=True)
99
+ def mode(*args):
100
+ list1 = list(args)
101
+ dict1 = {}
102
+ dict2 = {}
103
+ set1 = set(list1)
104
+ for j in set1:
105
+ dict1[j] = list1.count(j)
106
+ max_value = max(dict1.values())
107
+ count = [key for key, value in dict1.items() if value == max_value]
108
+ if max_value == 1:
109
+ return 'no mode'
110
+ elif len(count) == len(set1):
111
+ return 'no mode'
112
+ elif len(count) == 1:
113
+ dict2[count[0]] = dict1.get(count[0])
114
+ return dict2
115
+ elif len(count) == 2:
116
+ return 'bi mode'
117
+ elif len(count) == 3:
118
+ return 'tri mode'
119
+ else:
120
+ return 'multimode'
121
+ numbers_input = st.text_input("Enter a list of numbers separated by commas (e.g., 1, 2, 2, 3, 4):")
122
+
123
+ if numbers_input:
124
+ try:
125
+ list1 = list(map(int, numbers_input.split(',')))
126
+ result = mode(*list1)
127
+ st.write("Mode result:", result)
128
+ except ValueError:
129
+ st.write("Please enter a valid list of numbers separated by commas.")