Answers for "how to make the higher or lower using python"

1

how to make the higher or lower using python

from opponents import data
import random
from logos import logo, VS
import os

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)

    os.system("cls")
    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()
Posted by: Guest on September-02-2021
1

how to make the higher or lower using python

logo = '''                                                                                                
        ,--,                                                                                    
      ,--.'|                     ,---,                                                          
   ,--,  | :  ,--,             ,--.' |                                                          
,---.'|  : ',--.'|             |  |  :                __  ,-.           ,---.    __  ,-.        
|   | : _' ||  |,     ,----._,.:  :  :              ,' ,'/ /|          '   ,'\ ,' ,'/ /|        
:   : |.'  |`--'_    /   /  ' /:  |  |,--.   ,---.  '  | |' |         /   /   |'  | |' |        
|   ' '  ; :,' ,'|  |   :     ||  :  '   |  /     \ |  |   ,'        .   ; ,. :|  |   ,'        
'   |  .'. |'  | |  |   | .\  .|  |   /' : /    /  |'  :  /          '   | |: :'  :  /          
|   | :  | '|  | :  .   ; ';  |'  :  | | |.    ' / ||  | '           '   | .; :|  | '           
'   : |  : ;'  : |__'   .   . ||  |  ' | :'   ;   /|;  : |           |   :    |;  : |           
|   | '  ,/ |  | '.'|`---`-'| ||  :  :_:,''   |  / ||  , ;            \   \  / |  , ;           
;   : ;--'  ;  :    ;.'__/\_: ||  | ,'    |   :    | ---'              `----'   ---'            
|   ,/      |  ,   / |   :    :`--''       \   \  /                                             
'---'        ---`-'   \   \  /              `----'                                              
  ,--,                 `--`-'                                                                   
,--.'|                                                                                          
|  | :     ,---.           .---.            __  ,-.                                             
:  : '    '   ,'\         /. ./|          ,' ,'/ /|                                             
|  ' |   /   /   |     .-'-. ' |   ,---.  '  | |' |                                             
'  | |  .   ; ,. :    /___/ \: |  /     \ |  |   ,'                                             
|  | :  '   | |: : .-'.. '   ' . /    /  |'  :  /                                               
'  : |__'   | .; :/___/ \:     '.    ' / ||  | '                                                
|  | '.'|   :    |.   \  ' .\   '   ;   /|;  : |                                                
;  :    ;\   \  /  \   \   ' \ |'   |  / ||  , ;                                                
|  ,   /  `----'    \   \  |--" |   :    | ---'                                                 
 ---`-'              \   \ |     \   \  /                                                       
                      '---"       `----'           '''

VS = '''
       ,---.             
      /__./|             
 ,---.;  ; |  .--.--.    
/___/ \  | | /  /    '   
\   ;  \ ' ||  :  /`./   
 \   \  \: ||  :  ;_     
  ;   \  ' . \  \    `.  
   \   \   '  `----.   \ 
    \   `  ; /  /`--'  / 
     :   \ |'--'.     /  
      '---"   `--'---'   '''
Posted by: Guest on September-02-2021
0

how to make the higher or lower using python

data = [
    {
        'name': 'Instagram',
        'follower_count': 346,
        'description': 'Social media platform',
        'country': 'United States'
    },
    {
        'name': 'Cristiano Ronaldo',
        'follower_count': 215,
        'description': 'Footballer',
        'country': 'Portugal'
    },
    {
        'name': 'Kylie Jenner',
        'follower_count': 172,
        'description': 'Reality TV personality and businesswoman and Self-Made Billionaire',
        'country': 'United States'
    },
    {
        'name': 'Kim Kardashian',
        'follower_count': 167,
        'description': 'Reality TV personality and businesswoman',
        'country': 'United States'
    },
    {
        'name': 'Beyoncé',
        'follower_count': 145,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'Neymar',
        'follower_count': 138,
        'description': 'Footballer',
        'country': 'Brasil'
    },
    {
        'name': 'National Geographic',
        'follower_count': 135,
        'description': 'Magazine',
        'country': 'United States'
    },
    {
        'name': 'Justin Bieber',
        'follower_count': 133,
        'description': 'Musician',
        'country': 'Canada'
    },
    {
        'name': 'Taylor Swift',
        'follower_count': 131,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'Kendall Jenner',
        'follower_count': 127,
        'description': 'Reality TV personality and Model',
        'country': 'United States'
    },
    {
        'name': 'Nike',
        'follower_count': 109,
        'description': 'Sportswear multinational',
        'country': 'United States'
    },
    {
        'name': 'Khloé Kardashian',
        'follower_count': 108,
        'description': 'Reality TV personality and businesswoman',
        'country': 'United States'
    },
    {
        'name': 'Ellen DeGeneres',
        'follower_count': 87,
        'description': 'Comedian',
        'country': 'United States'
    },
    {
        'name': 'Real Madrid CF',
        'follower_count': 86,
        'description': 'Football club',
        'country': 'Spain'
    },
    {
        'name': 'FC Barcelona',
        'follower_count': 85,
        'description': 'Football club',
        'country': 'Spain'
    },
    {
        'name': 'Demi Lovato',
        'follower_count': 80,
        'description': 'Musician and actress',
        'country': 'United States'
    },
    {
        'name': "Victoria's Secret",
        'follower_count': 69,
        'description': 'Lingerie brand',
        'country': 'United States'
    },
    {
        'name': 'Zendaya',
        'follower_count': 68,
        'description': 'Actress and musician',
        'country': 'United States'
    },
    {
        'name': 'Chris Brown',
        'follower_count': 64,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'LeBron James',
        'follower_count': 63,
        'description': 'Basketball player',
        'country': 'United States'
    },
    {
        'name': 'Vin Diesel',
        'follower_count': 62,
        'description': 'Actor',
        'country': 'United States'
    },
    {
        'name': 'Cardi B',
        'follower_count': 67,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'Virat Kohli',
        'follower_count': 55,
        'description': 'Cricketer',
        'country': 'India'
    },
    {
        'name': 'Priyanka Chopra Jonas',
        'follower_count': 53,
        'description': 'Actress and musician',
        'country': 'India'
    }
]
Posted by: Guest on September-02-2021

Code answers related to "how to make the higher or lower using python"

Python Answers by Framework

Browse Popular Code Answers by Language