-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (22 loc) · 879 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def main():
st.title('Random Choice')
# options = []
choice1 = str(st.text_input('Choice 1'))
choice2 = str(st.text_input('Choice 2'))
flips = int(st.number_input('Number of total flips', min_value=1, max_value=1000000, step=1))
go = st.button("Let's begin")
if go:
options = [choice1,choice2]
score = pd.DataFrame([np.random.choice(options, p=[0.5,0.5]) for i in range(0,flips)])
count = score.value_counts(sort=False)
st.write('Total Count for %s: '%choice1, str(count[choice1]))
st.write('Total Count for %s: '%choice2, str(count[choice2]))
options.sort()
fig, ax = plt.subplots()
ax.pie(x=count, labels=options, autopct="%.1f%%")
st.pyplot(fig)
main()