Spaces:
Sleeping
Sleeping
File size: 859 Bytes
820fb78 |
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
# Title of the app
st.title("Simple Voting App")
# Description
st.write("Vote for your favorite option below:")
# Options for voting
options = ["Option A", "Option B", "Option C"]
# Initialize a dictionary to store votes
if "votes" not in st.session_state:
st.session_state.votes = {option: 0 for option in options}
# User selects an option
selected_option = st.radio("Choose an option:", options)
# Submit vote button
if st.button("Submit Vote"):
# Increment the vote count for the selected option
st.session_state.votes[selected_option] += 1
st.success(f"You voted for {selected_option}!")
# Display the voting results
st.write("### Voting Results:")
for option, count in st.session_state.votes.items():
st.write(f"{option}: {count} votes")
# Show bar chart of results
st.bar_chart(st.session_state.votes)
|