Spaces:
Build error
Build error
import streamlit as st | |
import wikipedia | |
import random | |
STEM_EMOJIS = ["🔬", "🧬", "🧪", "🔭", "🛰️", "🚀", "🛸", "🖥️", "💻", "📐"] | |
OTHER_EMOJIS = ["😀", "😂", "😊", "🎉", "🎁", "👍", "❤️", "🤔", "😍", "😜"] | |
def getScienceEmoji(): | |
return random.choice(STEM_EMOJIS) | |
def getwik(): | |
# get a random science article title from Wikipedia | |
article_title = wikipedia.random(pages=1) | |
st.write(f"Random Science Article: {article_title}") | |
# load the article content | |
article = wikipedia.page(article_title) | |
st.write(article.content) | |
# simulate two D100 dice rolls | |
roll1 = st.slider('Roll Dice 1', 1, 100, 1) | |
roll2 = st.slider('Roll Dice 2', 1, 100, 1) | |
total_roll = roll1 + roll2 | |
st.write(f"Dice Roll: {total_roll}") | |
# print the result with a random STEM or OTHER emoji | |
emoji = getScienceEmoji() if total_roll <= 50 else random.choice(OTHER_EMOJIS) | |
st.markdown(f"Result: {emoji} {article_title} - Roll: {total_roll}") | |
# example usage | |
getwik() | |