-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhigher_lower_by_angela_yu.py
More file actions
98 lines (69 loc) · 3.08 KB
/
higher_lower_by_angela_yu.py
File metadata and controls
98 lines (69 loc) · 3.08 KB
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
#import modules
#Generate a random account from the game data.
import random
from game_data import data
# Display art
logo = '''
___ ___ ___ ________ ___ ___ _______ ________ ___ ________ ___ __ _______ ________
|\ \|\ \|\ \|\ ____\|\ \|\ \|\ ___ \ |\ __ \ |\ \ |\ __ \|\ \ |\ \|\ ___ \ |\ __ \
\ \ \\\ \ \ \ \ \___|\ \ \\\ \ \ __/|\ \ \|\ \ \ \ \ \ \ \|\ \ \ \ \ \ \ \ __/|\ \ \|\ \
\ \ __ \ \ \ \ \ __\ \ __ \ \ \_|/_\ \ _ _\ \ \ \ \ \ \\\ \ \ \ __\ \ \ \ \_|/_\ \ _ _\
\ \ \ \ \ \ \ \ \|\ \ \ \ \ \ \ \_|\ \ \ \\ \| \ \ \____\ \ \\\ \ \ \|\__\_\ \ \ \_|\ \ \ \\ \|
\ \__\ \__\ \__\ \_______\ \__\ \__\ \_______\ \__\\ _\ \ \_______\ \_______\ \____________\ \_______\ \__\\ _\
\|__|\|__|\|__|\|_______|\|__|\|__|\|_______|\|__|\|__| \|_______|\|_______|\|____________|\|_______|\|__|\|__|
'''
print(logo)
def format_data(account):
"""Take the account data and convert it into printable format."""
account_name = account['name']
account_descr = account['description']
account_country = account['country']
return f"{account_name}, a {account_descr} from {account_country}"
def check_answer(guess, a_followers, b_followers):
"""Take the user guess and follower counts and returns if they got it right."""
if a_followers > b_followers:
return guess == 'a'
else:
return guess == 'b'
score = 0
game_should_continue = True
account_b = random.choice(data)
while game_should_continue:
account_a = account_b
account_b = random.choice(data)
if account_a == account_b:
account_b = random.choice(data)
print(f"Compare A: {format_data(account_a)}")
print('''
.----. .----.
\ \ / /
' '. /' /
| |' /
| || | _
'. `' .' .' |
\ / . | /
\ / .'.'| |//
'----'.'.'.-' /
.' \_.'
''')
print(f"Compare B: {format_data(account_b)}")
#Ask user for a guess.
guess = input("Who has more Followers? Type 'A' or 'B': ").lower()
#clear the screen
print("\n"*20)
print(logo)
#Get follower count.
a_follower_count = account_a['follower_count']
b_follower_count = account_b['follower_count']
#Use if statement to check if user is correct.
is_correct = check_answer(guess, a_follower_count, b_follower_count)
#Give user feedback on their guess.
if is_correct:
score += 1
print(f"You're right! Your current score is {score}.")
else:
print(f"Sorry, that's wrong! Final score is {score}.")
game_should_continue = False
#Score keeping.
#Make game repeatable.
#Making account at position B become the next account at position A.