File size: 2,260 Bytes
674e800
 
 
 
f7c14ac
674e800
2cf9255
674e800
f7c14ac
674e800
 
 
 
 
 
 
 
 
 
 
 
f7c14ac
 
 
 
 
 
 
674e800
f7c14ac
2cf9255
390f74d
2cf9255
390f74d
 
674e800
390f74d
 
7bd5976
2cf9255
7bd5976
 
 
 
 
390f74d
2cf9255
 
390f74d
7bd5976
2cf9255
7bd5976
 
 
 
 
674e800
390f74d
 
674e800
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import random
import streamlit as st

st.title("Welcome To Person Guessing Game!!")
st.header("I will describe a person and you need to guess who it is by their characteristics")

st.write("Here Is Your Choices: Gian, Kirby, Francys, JK, Cielo, Arki, Basti, Mico, and Jhay.")

def guess():
    people = {
        "Gian": ["Smart", "small", "hyper"],
        "Kirby": ["small", "loyal", "Loves badminton"],
        "Francys": ["serious", "smart", "quiet"],
        "JK": ["tall", "foot fetish", "talkative"],
        "Cielo": ["quiet", "Loves to watch peppapig", "Enjoys editing"],
        "Arki": ["talkative", "Loves blue by yung kai", "enjoys coding"],
        "Basti": ["Music lover", "tall", "Enjoys jamming with friends"],
        "Mico": ["smart", "Good at editing", "Enjoys coding"],
        "Jhay": ["kind", "Always making others laugh", "Loves to make friends laugh"]
    }

    if 'chosen_name' not in st.session_state:
        names = list(people.keys())
        index = random.randint(0, len(names) - 1)
        st.session_state.chosen_name = names[index]
        st.session_state.description = people[st.session_state.chosen_name] 
        st.session_state.attempts = 0
        st.session_state.max_attempts = 5

    st.write(f"Here's the description for the person: {', '.join(st.session_state.description)}")
    
    a, b = st.columns(2)
    guess = st.text_input("Who Do You Think It Is??")
    submit = a.button("submit")
    clear = b.button("clear")

    if submit:
     if guess.lower() == st.session_state.chosen_name.lower():
        st.success(f"CONGRATULATIONS!!! You Guessed It Correctly It Is {st.session_state.chosen_name}.") 
        st.stop()
        
      
     if st.session_state.attempts < st.session_state.max_attempts -1:
        RA = st.session_state.max_attempts - st.session_state.attempts
        st.warning(f"That's Not Correct. You Have {RA} attempts left .")
     else:
        st.error(f"Sorry, You're Out Of Attempts. The Correct Answer Was {st.session_state.chosen_name}.")
        st.stop()
   
   
     if clear:
        for key in ['chosen_name', 'description', 'attempts']:
            if key in st.session_state:
                del st.session_state[key]
      
     st.session_state.attempts += 1



guess()