Update pages/ex6: Pedra-paper-tisora.py
Browse files
pages/ex6: Pedra-paper-tisora.py
CHANGED
|
@@ -1,14 +1,11 @@
|
|
| 1 |
from random import*
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
-
n_tirades=
|
| 5 |
jugador=""
|
| 6 |
ordinador=""
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
while n_tirades!=1:
|
| 12 |
if st.button("Paper"):
|
| 13 |
jugador="Paper"
|
| 14 |
if st.button("Pedra"):
|
|
@@ -22,13 +19,11 @@ while n_tirades!=1:
|
|
| 22 |
|
| 23 |
if jugador=="Pedra" and ordinador=="Paper" or jugador=="Paper" and ordinador=="Tisora" or jugador=="Tisora" and ordinador=="Pedra":
|
| 24 |
st.write("Ordinador guanya")
|
| 25 |
-
|
| 26 |
elif jugador==ordinador:
|
| 27 |
st.write("Empat, torna a tirar")
|
| 28 |
else:
|
| 29 |
st.write("Jugador guanya")
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
if st.button("Jugar"):
|
| 33 |
-
n_tirades=n_tirades-1
|
| 34 |
|
|
|
|
|
|
| 1 |
from random import*
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
+
n_tirades=0
|
| 5 |
jugador=""
|
| 6 |
ordinador=""
|
| 7 |
|
| 8 |
+
while n_tirades==1:
|
|
|
|
|
|
|
|
|
|
| 9 |
if st.button("Paper"):
|
| 10 |
jugador="Paper"
|
| 11 |
if st.button("Pedra"):
|
|
|
|
| 19 |
|
| 20 |
if jugador=="Pedra" and ordinador=="Paper" or jugador=="Paper" and ordinador=="Tisora" or jugador=="Tisora" and ordinador=="Pedra":
|
| 21 |
st.write("Ordinador guanya")
|
| 22 |
+
break
|
| 23 |
elif jugador==ordinador:
|
| 24 |
st.write("Empat, torna a tirar")
|
| 25 |
else:
|
| 26 |
st.write("Jugador guanya")
|
| 27 |
+
break
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
|