Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,25 +46,31 @@ the key points of descriptive statistics are stated below.\n KEY COCEPTS\n * Mea
|
|
| 46 |
st.subheader("Measure Of Central Tendency",divider=True)
|
| 47 |
st.markdown("""The measure of central tendency is used to find the central average value of the data.The central tendency can be computed by
|
| 48 |
useing three ways \n * Mode \n * Median \n * Mean""")
|
| 49 |
-
def mode(
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
max_value=max(dict1.values())
|
| 57 |
-
count = [key for key, value in dict1.items() if value==max_value]
|
| 58 |
-
if max_value==1:
|
| 59 |
-
|
| 60 |
-
elif len(count)==len(set1):
|
| 61 |
-
|
| 62 |
-
elif len(count)==1:
|
| 63 |
-
dict2[count[0]]= dict1.get(count[0])
|
| 64 |
-
|
| 65 |
-
elif len(count)==2:
|
| 66 |
-
|
| 67 |
-
elif len(count)==3:
|
| 68 |
-
|
| 69 |
else:
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
st.subheader("Measure Of Central Tendency",divider=True)
|
| 47 |
st.markdown("""The measure of central tendency is used to find the central average value of the data.The central tendency can be computed by
|
| 48 |
useing three ways \n * Mode \n * Median \n * Mean""")
|
| 49 |
+
def mode(*args):
|
| 50 |
+
list1 = list(args)
|
| 51 |
+
dict1 = {}
|
| 52 |
+
dict2 = {}
|
| 53 |
+
set1 = set(list1)
|
| 54 |
+
for j in set1:
|
| 55 |
+
dict1[j] = list1.count(j)
|
| 56 |
+
max_value = max(dict1.values())
|
| 57 |
+
count = [key for key, value in dict1.items() if value == max_value]
|
| 58 |
+
if max_value == 1:
|
| 59 |
+
return 'no mode'
|
| 60 |
+
elif len(count) == len(set1):
|
| 61 |
+
return 'no mode'
|
| 62 |
+
elif len(count) == 1:
|
| 63 |
+
dict2[count[0]] = dict1.get(count[0])
|
| 64 |
+
return dict2
|
| 65 |
+
elif len(count) == 2:
|
| 66 |
+
return 'bi mode'
|
| 67 |
+
elif len(count) == 3:
|
| 68 |
+
return 'tri mode'
|
| 69 |
else:
|
| 70 |
+
return 'multimode'
|
| 71 |
+
|
| 72 |
+
# Call the mode function with specific arguments
|
| 73 |
+
result = mode(1, 2, 3, 3, 3)
|
| 74 |
+
|
| 75 |
+
# Display the result
|
| 76 |
+
st.write("Mode result:", result)
|