Juditttttttt commited on
Commit
b515024
1 Parent(s): 1cbda24

Create exercici7.py

Browse files
Files changed (1) hide show
  1. pages/exercici7.py +22 -0
pages/exercici7.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from random import *
2
+ import streamlit as st
3
+
4
+ st.title("Benvingut al joc Endevina el número secret.")
5
+ st.header("Aconsegueix-ho amb el nombre mínim d'intent")
6
+ intents = 0
7
+ secret = random.randint(1,101)
8
+
9
+ while True:
10
+ jugador = st.slider('Escull un valor', 1, 100)
11
+ if not jugador:
12
+ st.stop()
13
+
14
+ intents = intents + 1
15
+ if jugador == secret:
16
+ break
17
+ elif judador > secret:
18
+ st.write("Massa alt! Torna-ho a provar")
19
+ else:
20
+ st.write("Massa baix! Torna-ho a provar")
21
+
22
+ st.write(f"Has necessitat {intents} intents d'endevinar el número secret! GAME OVER")