File size: 1,040 Bytes
38532d2
dc94f5f
 
38532d2
dc94f5f
 
38532d2
dc94f5f
 
f6b145c
dc94f5f
 
 
 
38532d2
dc94f5f
 
 
38532d2
dc94f5f
 
 
 
 
38532d2
dc94f5f
 
 
38532d2
f6b145c
dc94f5f
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 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()