A fun and interactive Python-based guessing game where players compare the follower counts of different personalities. Test your intuition and knowledge while trying to achieve the highest score possible!
The Higher-Lower game is a simple yet engaging game where players are presented with two personalities and must guess which one has more followers. The game continues as long as the player makes correct guesses, with each correct guess adding to their score.
- Beautiful ASCII art interface
- Random selection of personalities from a data set
- Score tracking system
- Interactive command-line interface
- Continuous gameplay until wrong guess
The game is built using Python and consists of several key components:
-
Imports and Setup
import random import Data import logo
- The game utilizes the
random
module for selecting personalities - Custom modules
Data
andlogo
contain game data and ASCII art
- The game utilizes the
-
Data Formatting Function
def format_data(ac): name = ac["name"] Description = ac["Hobbies"] Country = ac["Country"] return f"{name} a {Description} from {Country}"
- Formats the personality data for display
- Shows name, hobbies, and country of origin
-
Comparison Function
def check_followers(f_1, f_2, user_guess): if f_1 > f_2 and user_guess == 'a': return True elif f_2 > f_1 and user_guess == 'b': return True else: return False
- Validates user guesses
- Compares follower counts
- Returns True for correct guesses, False otherwise
The main game loop:
- Randomly selects two different personalities
- Displays their information with VS screen
- Takes user input ('A' or 'B')
- Updates score for correct guesses
- Continues until an incorrect guess is made
- Run the Python script
- You'll be presented with two personalities, A and B
- Type 'A' or 'B' to guess who has more followers
- For each correct guess, your score increases by 1
- Game continues until you make a wrong guess
- Try to achieve the highest score possible!
- Clone the repository:
git clone https://github.com/Lakshitpythondevloper/Higher-Lower-game.git
- Navigate to the project directory:
cd Higher-Lower-game
- Run the game:
python Higher-Lower.py
The game follows this logical flow:
- Two random personalities are selected from the database
- Their information is displayed to the player
- Player makes a guess
- The follower counts are compared
- Score is updated if correct
- Game continues with new personalities if correct
- Game ends if guess is incorrect
- Uses Python's
random.choice()
to select personalities - Ensures no duplicate selections in the same round
- Maintains a running score (
Current_score
) - Displays score before each round
- Final score shown when game ends
- Checks for duplicate personality selection
- Handles case-insensitive user input
- Clear feedback on game end
- Python 3.x
- Custom modules:
Data.py
(contains personality database)logo.py
(contains ASCII art)
Game_data = [
{
"name" : "Cristiano Ronaldo",
"Followers_count" : 630,
"Country" : "Portugal",
"Hobbies" : "Footballer"
},
{
"name" : "Lionel Messi",
"Followers_count" : 500,
"Country" : "Argentina",
"Hobbies" : "Footballer"
},
{
"name" : "Taylor Swift",
"Followers_count" : 450,
"Country" : "USA",
"Hobbies" : "Singer"
},
{
"name": "Selena Gomez",
"Followers_count": 430,
"Country": "USA",
"Hobbies": "Singer"
},
{
"name": "Dwayne Johnson",
"Followers_count": 390,
"Country": "USA",
"Hobbies": "Actor"
},
{
"name": "Kim Kardashian",
"Followers_count": 360,
"Country": "USA",
"Hobbies": "Media personality"
},
{
"name": "Neymar Jr.",
"Followers_count": 360,
"Country": "Brazil",
"Hobbies": "Footballer"
},
{
"name": "Virat Kohli",
"Followers_count": 270,
"Country": "India",
"Hobbies": "Cricketer"
},
{
"name": "Virat Kohli",
"Followers_count": 270,
"Country": "India",
"Hobbies": "Cricketer"
},
{
"name": "Narendra Modi ji",
"Followers_count": 250,
"Country": "India",
"Hobbies": "Prime Minister"
},
{
"name": "B.T.S",
"Followers_count": 100,
"Country": "South Korea",
"Hobbies": "K-pop Artist"
}
]
Feel free to fork this repository and submit pull requests to contribute to this project. You can also open issues for bugs or feature requests.
This project is open source and available under the MIT License.
Happy Gaming! 🎮