awacke1's picture
Update app.py
0dd8606
raw
history blame contribute delete
791 Bytes
# write a python streamlit program which allows two players to play the dice game called Craps.
import streamlit as st
import random
st.title("Craps Game")
# player1
player1_name = st.text_input("Player 1 name :")
st.write("Hi",player1_name,"Let's play Craps")
# player2
player2_name = st.text_input("Player 2 name :")
st.write("Hi",player2_name,"Let's play Craps")
# Craps game
st.write("Let's roll the dice")
# player1
player1_roll = random.randint(2,12)
st.write(player1_name,"rolled a", player1_roll)
# player2
player2_roll = random.randint(2,12)
st.write(player2_name,"rolled a", player2_roll)
# game result
if player1_roll > player2_roll:
st.write(player1_name,"wins!")
elif player2_roll > player1_roll:
st.write(player2_name,"wins!")
else:
st.write("It's a tie!")