File size: 791 Bytes
0dd8606
30f09c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
# 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!")