awacke1's picture
Create app.py
0c664d5
raw
history blame
1.15 kB
# Streamlit Game of Life
#Accept inline code suggestion — Tab
#Dismiss inline code suggestion — Esc
#Show next suggestion — Alt + ] or Option (⌥) + ]
#Show previous suggestion — Alt + [ or Option (⌥) + [
#Trigger suggestion — Alt + \ or Option (⌥) + \
#Open ten suggestions in a separate pane — Ctrl + Enter
# Dice Roll Game
import streamlit as st
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
st.title('Dice Roll Game')
st.write('This is a dice roll game. Roll the dice and get the highest number')
def roll_dice():
return np.random.randint(1, 7)
if st.button('Roll the Dice'):
roll1 = roll_dice()
roll2 = roll_dice()
st.write('You rolled a', roll1, 'and a', roll2)
if roll1 == roll2:
st.write('You win! You got a pair of', roll1, 's!')
else:
st.write('You lose! Try again!')
num_rolls = st.slider('How many times do you want to roll the dice?', 1, 1000, 100)
rolls = [roll_dice() for i in range(num_rolls)]
fig, ax = plt.subplots()
sns.histplot(rolls, kde=False, ax=ax)
ax.set_xlabel('Dice Roll')
ax.set_ylabel('Frequency')
st.pyplot(fig)