|
2 | 2 | import time |
3 | 3 | import os |
4 | 4 |
|
5 | | -def clear(): |
6 | | - if os.name == "nt": |
7 | | - os.system('cls') |
8 | | - else: |
9 | | - os.system('clear') |
10 | | - |
11 | | -print("In this program you will need to guess the country I am thinking of") |
12 | | - |
13 | | -print("") |
14 | | -print("") |
15 | | - |
16 | | -print("Difficulties:") |
17 | | -print("1. Normal") |
18 | | -print("2. Hard") |
19 | | -print("") |
20 | | -print("") |
21 | | - |
22 | | -difficulty = input("Please choose difficulty: ") |
23 | | - |
24 | | -difficultylevel = int(difficulty) |
25 | | -clear() |
26 | | - |
27 | | -if difficultylevel < 2: |
28 | | - randomcountry = random.randint(1, 10) |
29 | | -else: |
30 | | - randomcountry = random.randint(1, 20) |
31 | | -wrongguesses = 0 |
32 | | -if randomcountry == 1: |
33 | | - country = "Spain" |
34 | | - region = "Europe" |
35 | | - |
36 | | -if randomcountry == 2: |
37 | | - country = "US" |
38 | | - region = "America" |
39 | | - |
40 | | -if randomcountry == 3: |
41 | | - country = "UK" |
42 | | - region = "Europe" |
43 | | - |
44 | | -if randomcountry == 4: |
45 | | - country = "Poland" |
46 | | - region = "Europe" |
47 | | - |
48 | | -if randomcountry == 5: |
49 | | - country = "France" |
50 | | - region = "Europe" |
51 | | - |
52 | | -if randomcountry == 6: |
53 | | - country = "Australia" |
54 | | - region = "Oceania" |
55 | | - |
56 | | -if randomcountry == 7: |
57 | | - country = "Italy" |
58 | | - region = "Europe" |
59 | | - |
60 | | -if randomcountry == 8: |
61 | | - country = "Portugal" |
62 | | - region = "Europe" |
63 | | - |
64 | | -if randomcountry == 9: |
65 | | - country = "Finland" |
66 | | - region = "Europe" |
67 | | - |
68 | | -if randomcountry == 10: |
69 | | - country = "Scotland" |
70 | | - region = "Europe" |
71 | | - |
72 | | -if randomcountry == 11: |
73 | | - country = "Indonesia" |
74 | | - region = "Asia" |
75 | | - |
76 | | -if randomcountry == 12: |
77 | | - country = "India" |
78 | | - region = "Asia" |
| 5 | +COUNTRIES_NORMAL = [ |
| 6 | + ("Spain", "Europe"), |
| 7 | + ("US", "America"), |
| 8 | + ("UK", "Europe"), |
| 9 | + ("Poland", "Europe"), |
| 10 | + ("France", "Europe"), |
| 11 | + ("Australia", "Oceania"), |
| 12 | + ("Italy", "Europe"), |
| 13 | + ("Portugal", "Europe"), |
| 14 | + ("Finland", "Europe"), |
| 15 | + ("Scotland", "Europe"), |
| 16 | +] |
| 17 | + |
| 18 | +COUNTRIES_HARD = COUNTRIES_NORMAL + [ |
| 19 | + ("Indonesia", "Asia"), |
| 20 | + ("India", "Asia"), |
| 21 | + ("Japan", "Asia"), |
| 22 | + ("Germany", "Europe"), |
| 23 | + ("Denmark", "Europe"), |
| 24 | + ("Algeria", "Africa"), |
| 25 | + ("Iceland", "Europe"), |
| 26 | + ("Ukraine", "Europe"), |
| 27 | + ("Greece", "Europe"), |
| 28 | + ("Ireland", "Europe"), |
| 29 | +] |
| 30 | + |
| 31 | +WRONG_PHRASES = [ |
| 32 | + "That was an interesting guess, but not quite.", |
| 33 | + "That was not right :(", |
| 34 | + "Nice guess, but it's not this one.", |
| 35 | + "Nuh uh", |
| 36 | + "Wrong guess", |
| 37 | +] |
| 38 | + |
| 39 | +WON_PHRASES = [ |
| 40 | + "You won!", |
| 41 | + "Congratulations, you guessed it right!", |
| 42 | + "GGs, you guessed it right!", |
| 43 | +] |
79 | 44 |
|
80 | | -if randomcountry == 13: |
81 | | - country = "Japan" |
82 | | - region = "Asia" |
83 | 45 |
|
84 | | -if randomcountry == 14: |
85 | | - country = "Germany" |
86 | | - region = "Europe" |
87 | | - |
88 | | -if randomcountry == 15: |
89 | | - country = "Denmark" |
90 | | - region = "Europe" |
91 | | - |
92 | | -if randomcountry == 16: |
93 | | - country = "Algeria" |
94 | | - region = "Africa" |
95 | | - |
96 | | -if randomcountry == 17: |
97 | | - country = "Iceland" |
98 | | - region = "Europe" |
99 | | - |
100 | | -if randomcountry == 18: |
101 | | - country = "Ukraine" |
102 | | - region = "Europe" |
103 | | - |
104 | | -if randomcountry == 19: |
105 | | - country = "Greece" |
106 | | - region = "Europe" |
107 | | - |
108 | | -if randomcountry == 20: |
109 | | - country = "Ireland" |
110 | | - region = "Europe" |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | -if difficultylevel < 2: |
116 | | - print(f"I am thinking of a country in {region}. Good luck.") |
117 | | -else: |
118 | | - print("I am thinking of a country between the US and Japan. Good luck.") |
119 | | - |
120 | | -while True: |
121 | | - guess = input("Please enter your guess: ") |
122 | | - |
123 | | - if guess.lower() != country.lower(): |
124 | | - randomphrases = random.randint(1, 5) |
125 | | - wrongguesses = wrongguesses + 1 |
126 | | - if randomphrases == 1: |
127 | | - print("That was a interesting guess, but not quite.") |
128 | | - if randomphrases == 2: |
129 | | - print("That was not right :(") |
130 | | - if randomphrases == 3: |
131 | | - print("Nice guess, but it's not this one.") |
132 | | - if randomphrases == 4: |
133 | | - print("Nuh uh") |
134 | | - if randomphrases == 5: |
135 | | - print("Wrong guess") |
136 | | - if guess.lower() == country.lower(): |
137 | | - wonrandomphrases = random.randint(1, 3) |
138 | | - if wrongguesses > 5: |
139 | | - print("It's not that one you noob") |
140 | | - time.sleep(2) |
141 | | - print("Nah just kidding you got it right") |
| 46 | +def clear(): |
| 47 | + if os.name == "nt": |
| 48 | + os.system("cls") |
| 49 | + else: |
| 50 | + os.system("clear") |
| 51 | + |
| 52 | + |
| 53 | +def main(): |
| 54 | + print("In this program you will need to guess the country I am thinking of") |
| 55 | + print("\n\nDifficulties:") |
| 56 | + print("1. Normal") |
| 57 | + print("2. Hard\n\n") |
| 58 | + |
| 59 | + difficulty = int(input("Please choose difficulty: ")) |
| 60 | + clear() |
| 61 | + |
| 62 | + pool = COUNTRIES_HARD if difficulty >= 2 else COUNTRIES_NORMAL |
| 63 | + country, region = random.choice(pool) |
| 64 | + wrong_guesses = 0 |
| 65 | + |
| 66 | + if difficulty < 2: |
| 67 | + print(f"I am thinking of a country in {region}. Good luck.") |
| 68 | + else: |
| 69 | + print("I am thinking of a country between the US and Japan. Good luck.") |
| 70 | + |
| 71 | + while True: |
| 72 | + guess = input("Please enter your guess: ") |
| 73 | + |
| 74 | + if guess.lower() != country.lower(): |
| 75 | + wrong_guesses += 1 |
| 76 | + print(random.choice(WRONG_PHRASES)) |
| 77 | + else: |
| 78 | + if wrong_guesses > 5: |
| 79 | + print("It's not that one you noob") |
| 80 | + time.sleep(2) |
| 81 | + print("Nah just kidding you got it right") |
| 82 | + else: |
| 83 | + print(random.choice(WON_PHRASES)) |
142 | 84 | input() |
143 | | - exit() |
| 85 | + break |
144 | 86 |
|
145 | | - if wonrandomphrases == 1: |
146 | | - print("You won!") |
147 | | - input() |
148 | | - exit() |
149 | | - if wonrandomphrases == 2: |
150 | | - print("Congratulations, you guessed it right!") |
151 | | - input() |
152 | | - exit() |
153 | 87 |
|
154 | | - if wonrandomphrases == 3: |
155 | | - print("GGs, you guessed it right!") |
156 | | - input() |
157 | | - exit() |
| 88 | +if __name__ == "__main__": |
| 89 | + main() |
0 commit comments