Create a Python game that is similar to the Higher or Lower game available at https://www.higherlowergame.com/. This game will test the player’s knowledge of search engine query popularity.

Question:

“Can you design and implement a Python program that simulates a fun and interactive game based on Instagram follower counts? This program will not only help you learn Python but also reinforce your understanding of fundamental programming concepts.

Here’s a breakdown of what the program should do:

  1. Import necessary modules like random and create a data structure with Instagram account information.
  2. Define functions to:
    • Get a random Instagram account from the data.
    • Format account data for display.
    • Check if the user’s guess is correct based on follower counts.
    • Implement the game logic.
  3. Create a game loop that continues until the user guesses incorrectly.
  4. Display account information and ask the user to guess which account has more followers (‘A’ or ‘B’).
  5. Keep track of the user’s score.
  6. Provide feedback to the user after each guess and display the final score at the end.

Now, the challenge is for you to implement this program step by step. It will involve using variables, functions, loops, conditionals, and external data. As you work through the implementation, you’ll gain valuable experience in Python programming and problem-solving.

Are you ready to start this exciting Python programming journey? Let’s begin!”

Bonus Features (Optional):

  1. Implement a difficulty level system (easy, medium, hard) that affects the timer duration.
  2. Add a feature to allow players to view the search queries’ details, such as search volume or trends.
  3. Incorporate graphics or ASCII art to make the game visually appealing.
  4. Enable players to save their game progress and resume later.
  5. Implement a feature to share the player’s score on social media.

Evaluation Criteria:

  1. Functionality: Does the game meet the specified requirements?
  2. User Experience: Is the game easy to understand and play?
  3. Error Handling: Are there appropriate error checks for user inputs?
  4. Scoring System: Does the game calculate and display scores accurately?
  5. Timer: Is the timer implemented correctly?
  6. Leaderboard: Does the leaderboard accurately reflect the top scores?
  7. Bonus Features: Are any optional bonus features implemented successfully?

Submission: Students should submit their Python code in comments along with any necessary instructions on how to run the game.

HINT

Instructions:

  1. Import the necessary modules:
    • Import the random module for random data selection.
    • Import the data variable containing Instagram account information.
  2. Define the get_random_account() function:
    • This function should return random account data from the provided data variable.
  3. Define the format_data(account) function:
    • This function takes an account dictionary as input and formats it into a printable string with the following format: “name, a description, from country”.
  4. Define the check_answer(guess, a_followers, b_followers) function:
    • This function checks if the user’s guess (‘a’ or ‘b’) is correct by comparing the follower counts of accounts A and B. It returns True if the guess is correct and False otherwise.
  5. Define the game() function:
    • Initialize a score variable to keep track of the user’s score.
    • Initialize a game_should_continue variable to control the game loop.
    • Select two random Instagram accounts as account_a and account_b.
    • Start a while loop that continues as long as game_should_continue is True.
    • Inside the loop:
      • Update account_a to be account_b and select a new random account as account_b.
      • Ensure that account_a and account_b are not the same.
      • Display the names and descriptions of accounts A and B to the user.
      • Prompt the user to guess which account has more followers (type ‘A’ or ‘B’).
      • Get the follower counts for accounts A and B.
      • Use the check_answer() function to check if the user’s guess is correct.
      • If the guess is correct, increment the user’s score and display the current score.
      • If the guess is incorrect, set game_should_continue to False to end the game.
    • After the game loop ends, display the final score to the user.
  6. Call the game() function to start the game.

Day 14 : Solution : Python Higher Lower Game

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *