Anbumani commited on
Commit
820fb78
·
verified ·
1 Parent(s): cb25dce

app commit

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title of the app
4
+ st.title("Simple Voting App")
5
+
6
+ # Description
7
+ st.write("Vote for your favorite option below:")
8
+
9
+ # Options for voting
10
+ options = ["Option A", "Option B", "Option C"]
11
+
12
+ # Initialize a dictionary to store votes
13
+ if "votes" not in st.session_state:
14
+ st.session_state.votes = {option: 0 for option in options}
15
+
16
+ # User selects an option
17
+ selected_option = st.radio("Choose an option:", options)
18
+
19
+ # Submit vote button
20
+ if st.button("Submit Vote"):
21
+ # Increment the vote count for the selected option
22
+ st.session_state.votes[selected_option] += 1
23
+ st.success(f"You voted for {selected_option}!")
24
+
25
+ # Display the voting results
26
+ st.write("### Voting Results:")
27
+ for option, count in st.session_state.votes.items():
28
+ st.write(f"{option}: {count} votes")
29
+
30
+ # Show bar chart of results
31
+ st.bar_chart(st.session_state.votes)