-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10_higer_lower_modified.py
148 lines (136 loc) · 3.95 KB
/
10_higer_lower_modified.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import random
logo = """
__ ___ __
/ / / (_)___ _/ /_ ___ _____
/ /_/ / / __ `/ __ \/ _ \/ ___/
/ __ / / /_/ / / / / __/ /
/_/ ///_/\__, /_/ /_/\___/_/
/ / /____/_ _____ _____
/ / / __ \ | /| / / _ \/ ___/
/ /___/ /_/ / |/ |/ / __/ /
/_____/\____/|__/|__/\___/_/
"""
data = [
{
'name': 'Instagram',
'follower_count': 346,
'description': 'Social media platform',
'country': 'United States'
},
{
'name': 'Cristiano Ronaldo',
'follower_count': 215,
'description': 'Footballer',
'country': 'Portugal'
},
{
'name': 'Ariana Grande',
'follower_count': 183,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': 'Dwayne Johnson',
'follower_count': 181,
'description': 'Actor and professional wrestler',
'country': 'United States'
},
{
'name': 'Selena Gomez',
'follower_count': 174,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': 'Kim Kardashian',
'follower_count': 167,
'description': 'Reality TV personality and businesswoman',
'country': 'United States'
},
{
'name': 'Lionel Messi',
'follower_count': 149,
'description': 'Footballer',
'country': 'Argentina'
},
{
'name': 'Beyoncé',
'follower_count': 145,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'Neymar',
'follower_count': 138,
'description': 'Footballer',
'country': 'Brasil'
},
{
'name': 'Justin Bieber',
'follower_count': 133,
'description': 'Musician',
'country': 'Canada'
},
{
'name': 'Taylor Swift',
'follower_count': 131,
'description': 'Musician',
'country': 'United States'
},
{
'name': 'Jennifer Lopez',
'follower_count': 119,
'description': 'Musician and actress',
'country': 'United States'
},
{
'name': 'Nicki Minaj',
'follower_count': 113,
'description': 'Musician',
'country': 'Trinidad and Tobago'
}]
def get_random_account():
"""Get data from random account"""
return random.choice(data)
def format_data(account):
"""Format account into printable format: name, description and country"""
name = account["name"]
description = account["description"]
country = account["country"]
# print(f'{name}: {account["follower_count"]}')
return f"{name}, a {description}, from {country}"
def check_answer(guess, a_followers, b_followers):
"""Checks followers against user's guess
and returns True if they got it right.
Or False if they got it wrong."""
if a_followers > b_followers:
return guess == "a"
else:
return guess == "b"
def game():
print(logo)
score = 0
game_should_continue = True
account_a = get_random_account()
account_b = get_random_account()
while game_should_continue:
account_a = account_b
account_b = get_random_account()
while account_a == account_b:
account_b = get_random_account()
print(f"Compare A: {format_data(account_a)}.")
print(vs)
print(f"Against B: {format_data(account_b)}.")
guess = input("Who has more followers? Type 'A' or 'B': ").lower()
a_follower_count = account_a["follower_count"]
b_follower_count = account_b["follower_count"]
is_correct = check_answer(guess, a_follower_count, b_follower_count)
clear()
print(logo)
if is_correct:
score += 1
print(f"You're right! Current score: {score}.")
else:
game_should_continue = False
print(f"Sorry, that's wrong. Final score: {score}")
game()