Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from art import logo
- from art import vs
- from game_data import data
- import random
- import os
- def pick_a_person():
- """Picks a random person from data list containing dictionaries with sets of persons and their attributes"""
- return random.choice(data)
- def who_has_more(person_a, person_b):
- """Determines whom from the A&B pair has more followers and returns a string with an answer"""
- if person_a['follower_count'] > person_b['follower_count']:
- return "a"
- else:
- return "b"
- def add_score(score):
- """Takes current score and adds one more point"""
- return score + 1
- def clear_screen():
- os.system('cls')
- def play_game():
- person_a = pick_a_person()
- answer = ""
- score = 0
- is_game_over = False
- while not is_game_over:
- person_b = pick_a_person()
- while person_b == person_a:
- person_b = pick_a_person()
- print(logo)
- if score >= 1:
- print(f"You are right! Current score: {score}.")
- print(f"Compare A: {person_a['follower_count']} {person_a['name']}, a {person_a['description']}, from {person_a['country']}.")
- print(vs)
- print(f"Compare B: {person_b['follower_count']} {person_b['name']}, a {person_b['description']}, from {person_b['country']}.")
- guess = str(input("Who has more followers? Type 'A' or 'B': ")).lower()
- answer = who_has_more(person_a, person_b)
- if guess == answer:
- clear_screen()
- score = add_score(score)
- person_a = person_b
- else:
- clear_screen()
- print(logo)
- print(f"Sorry, that's wrong. Final score: {score}.")
- is_game_over = True
- play_game()
Advertisement
Add Comment
Please, Sign In to add comment