Anbumani's picture
app commit
820fb78 verified
raw
history blame contribute delete
859 Bytes
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)