Skip to content

Commit 0765566

Browse files
Merge pull request #2856 from Shikhar9425/master-10
Zoombinis.py
2 parents 1c696ff + d64c365 commit 0765566

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

Zoombinis/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Package/Script Name: Simplified Text-Based Zoombinis Game
2+
3+
Short description of package/script: This script is a simplified text-based version of the Zoombinis game. It allows players to select teams and individual Zoombinis.
4+
5+
Functionalities/Script:
6+
7+
Create and display teams of Zoombinis.
8+
Allow players to select a team and a Zoombini from that team.
9+
Setup Instructions:
10+
11+
Ensure you have Python installed on your system.
12+
Copy and paste the provided code into a file named zoombinis_game.py.
13+
How to Run:
14+
15+
Open a terminal or command prompt.
16+
Navigate to the directory where zoombinis_game.py is located.
17+
Run the script using the command:
18+
bash
19+
Copy code
20+
python zoombinis_game.py
21+
Follow the on-screen instructions to select teams and Zoombinis.
22+
Detailed Explanation:
23+
This script provides a simple text-based interface for a basic Zoombinis game. It defines functions to set up teams of Zoombinis, display teams, and allow players to select a team and a specific Zoombini from that team. The game loop continues until the player decides to exit.
24+
25+
Output:
26+
The script will display team information, allow the player to select a team and Zoombini, and provide prompts and feedback based on the player's choices.
27+
28+
Author:
29+
Shikhar9425

Zoombinis/Zoombinis.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import random
2+
3+
# Constants
4+
ZOOMBINIS_COUNT = 16
5+
ZOOMBINIS_PER_TEAM = 8
6+
7+
# Functions
8+
def setup_teams():
9+
teams = []
10+
for i in range(2):
11+
team = []
12+
for _ in range(ZOOMBINIS_PER_TEAM):
13+
team.append(random.randint(1, 4))
14+
teams.append(team)
15+
return teams
16+
17+
def display_teams(teams):
18+
for i, team in enumerate(teams, start=1):
19+
print(f"Team {i}: {team}")
20+
21+
def main():
22+
print("Welcome to Zoombinis!")
23+
teams = setup_teams()
24+
25+
while True:
26+
display_teams(teams)
27+
team_choice = int(input("Select a team (1 or 2): "))
28+
29+
if team_choice < 1 or team_choice > 2:
30+
print("Invalid team choice. Please select 1 or 2.")
31+
continue
32+
33+
selected_team = teams[team_choice - 1]
34+
zoombini_choice = int(input("Select a Zoombini (1-8): "))
35+
36+
if zoombini_choice < 1 or zoombini_choice > 8:
37+
print("Invalid Zoombini choice. Please select a number between 1 and 8.")
38+
continue
39+
40+
zoombini = selected_team[zoombini_choice - 1]
41+
print(f"Selected Zoombini: {zoombini}")
42+
43+
play_again = input("Do you want to play again? (y/n): ")
44+
if play_again.lower() != "y":
45+
print("Thanks for playing Zoombinis!")
46+
break
47+
48+
if __name__ == "__main__":
49+
main()

0 commit comments

Comments
 (0)