awacke1 commited on
Commit
0c664d5
·
1 Parent(s): 5a8cd7e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Streamlit Game of Life
2
+
3
+ #Accept inline code suggestion — Tab
4
+ #Dismiss inline code suggestion — Esc
5
+ #Show next suggestion — Alt + ] or Option (⌥) + ]
6
+ #Show previous suggestion — Alt + [ or Option (⌥) + [
7
+ #Trigger suggestion — Alt + \ or Option (⌥) + \
8
+ #Open ten suggestions in a separate pane — Ctrl + Enter
9
+
10
+ # Dice Roll Game
11
+
12
+ import streamlit as st
13
+ import numpy as np
14
+ import pandas as pd
15
+ import matplotlib.pyplot as plt
16
+ import seaborn as sns
17
+
18
+ st.title('Dice Roll Game')
19
+ st.write('This is a dice roll game. Roll the dice and get the highest number')
20
+
21
+ def roll_dice():
22
+ return np.random.randint(1, 7)
23
+
24
+ if st.button('Roll the Dice'):
25
+ roll1 = roll_dice()
26
+ roll2 = roll_dice()
27
+ st.write('You rolled a', roll1, 'and a', roll2)
28
+ if roll1 == roll2:
29
+ st.write('You win! You got a pair of', roll1, 's!')
30
+ else:
31
+ st.write('You lose! Try again!')
32
+
33
+ num_rolls = st.slider('How many times do you want to roll the dice?', 1, 1000, 100)
34
+ rolls = [roll_dice() for i in range(num_rolls)]
35
+ fig, ax = plt.subplots()
36
+ sns.histplot(rolls, kde=False, ax=ax)
37
+ ax.set_xlabel('Dice Roll')
38
+ ax.set_ylabel('Frequency')
39
+ st.pyplot(fig)
40
+