awacke1 commited on
Commit
dc94f5f
·
1 Parent(s): f6b145c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -28
app.py CHANGED
@@ -1,37 +1,31 @@
1
  import streamlit as st
2
- import pandas as pd
3
- import pydeck as pdk
4
 
5
- def show_pydeck_scatterplot(data_url):
6
- # create a container for the map and controls
7
- container = st.container()
8
 
9
- # load the data
10
- data = pd.read_csv(data_url, usecols=['latitude', 'longitude', 'time'])
11
 
12
- # create the scatter plot layer
13
- scatter_layer = pdk.Layer(
14
- 'ScatterplotLayer',
15
- data=data,
16
- get_position='[longitude, latitude]',
17
- get_color='[200, 30, time / 100]',
18
- get_radius=100,
19
- pickable=True,
20
- )
21
 
22
- # create the PyDeck view
23
- view = pdk.ViewState(latitude=data['latitude'].mean(),
24
- longitude=data['longitude'].mean(),
25
- zoom=10,
26
- pitch=50)
27
 
28
- # create the PyDeck map
29
- map = pdk.Deck(layers=[scatter_layer], initial_view_state=view)
 
 
 
30
 
31
- # add the PyDeck map to the container
32
- with container:
33
- st.pydeck_chart(map)
34
 
35
  # example usage
36
- data_url = 'https://data.cityofnewyork.us/api/views/7x9x-zpz6/rows.csv?accessType=DOWNLOAD'
37
- show_pydeck_scatterplot(data_url)
 
1
  import streamlit as st
2
+ import wikipedia
3
+ import random
4
 
5
+ STEM_EMOJIS = ["🔬", "🧬", "🧪", "🔭", "🛰️", "🚀", "🛸", "🖥️", "💻", "📐"]
6
+ OTHER_EMOJIS = ["😀", "😂", "😊", "🎉", "🎁", "👍", "❤️", "🤔", "😍", "😜"]
 
7
 
8
+ def getScienceEmoji():
9
+ return random.choice(STEM_EMOJIS)
10
 
11
+ def getwik():
12
+ # get a random science article title from Wikipedia
13
+ article_title = wikipedia.random(pages=1)
14
+ st.write(f"Random Science Article: {article_title}")
 
 
 
 
 
15
 
16
+ # load the article content
17
+ article = wikipedia.page(article_title)
18
+ st.write(article.content)
 
 
19
 
20
+ # simulate two D100 dice rolls
21
+ roll1 = st.slider('Roll Dice 1', 1, 100, 1)
22
+ roll2 = st.slider('Roll Dice 2', 1, 100, 1)
23
+ total_roll = roll1 + roll2
24
+ st.write(f"Dice Roll: {total_roll}")
25
 
26
+ # print the result with a random STEM or OTHER emoji
27
+ emoji = getScienceEmoji() if total_roll <= 50 else random.choice(OTHER_EMOJIS)
28
+ st.markdown(f"Result: {emoji} {article_title} - Roll: {total_roll}")
29
 
30
  # example usage
31
+ getwik()