-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,93 @@ | ||
|
||
import random | ||
from math import * | ||
|
||
|
||
#lists of animals types | ||
|
||
water = [ | ||
"Crab", "Fish", "Seal", "Octopus", "Shark", "Starfish", "Whale", "Penguin", | ||
"Jellyfish", "Squid", "Lobster", "Pelican", "Seahorse", "Walrus", "Shrimp", | ||
"Oyster", "Clams", "Seagull", "Dolphin", "Shells", "Sea urchin", "Cormorant", | ||
"Otter", "Pelican", "Sea anemone", "Sea turtle", "Sea lion", "Coral", | ||
"Water Turtle", "Crocodile", "Killer Whale", "Sea Lion", "Sea Anemone", | ||
"Angelfish", "Blue Whale", "Piranha", "Platypus", "Tuna", "Eal", "Salmon", | ||
"Goldfish", "Abalone", "Albacore", "Anchovy", "Angelfish", "Barnacle", | ||
"Barracuda", "Blue Crab", "Blue Whale", "Bull Shark", "Cleaner wrasse", | ||
"Clownfish", "Cod", "Conch", "Coral", "Crown of Thorns", "Cuttlefish", | ||
"Dolphin", "Dottyback", "Dragonet", "Driftfish", "Dugong or Sea Cow", | ||
"Dungeness Crab", "Eel", "Elephant Seal", "Emperor Shrimp", | ||
"Estuarine Crocodile", "Fan Worm", "Flounder", "Flying Fish", "Fugu", | ||
"Giant Squid", "Great White Shark", "Grouper", "Grunion", "Haddock", | ||
"Hake", "Halibut", "Herring", "Humpback Whale", "Irukandji", "Isopods", | ||
"Jellyfish", "John Dory", "Killer Whale or Orca", "King Mackerel or Kingfish", | ||
"Krill", "Lamprey", "Leafy Sea Dragon", "Ling", "Lionfish", "Lobster", | ||
"Mackerel", "Mahi-mahi or Dorado", "Manatee or Sea Cow", "Manta Ray", | ||
"Megalodon", "Mulloway", "Mussel", "Narwhal" | ||
"Crab", "Fish", "Seal", "Shark", "Starfish", "Whale", "Penguin", | ||
"Jellyfish", "Lobster", "Pelican", "Seahorse", "Walrus", "Shrimp", | ||
"Oyster", "Clams", "Seagull", "Dolphin", "Cormorant", "Otter", "Angelfish", | ||
"Blue Whale", "Tuna", "Salmon", "Goldfish", "Barnacle", "Bull Shark", | ||
"Clownfish", "Cod", "Conch", "Coral", "Cuttlefish", "Dolphin", "Fan Worm", | ||
"Flounder", "Flying Fish", "Grouper", "Haddock", "Halibut", "Herring", | ||
"Humpback Whale", "Jellyfish", "Ling", "Lobster", "Mackerel", "Mussel" | ||
] | ||
|
||
wild = [ | ||
"Tiger", "Lion", "Elephant", "Leopard", "Panther", "Cheetah", "Wolf", "Jaguar", | ||
"Hyena", "Giraffe", "Deer", "Zebra", "Gorilla", "Monkey", "Chimpanzee", "Bear", | ||
"Wild Boar", "Hippopotamus", "Kangaroo", "Rhinoceros", "Crocodile", "Panda", | ||
"Squirrel", "Mongoose", "Porcupine", "Koala Bear", "Wombat", "Meerkat", "Otter", | ||
"Hedgehog", "Possum", "Chipmunk", "Squirrel", "Raccoon", "Jackal", "Hare", "Mole", | ||
"Rabbit", "Alligator", "Monitor Lizard", "Oryx", "Elk", "Badger", "Dinosaur", | ||
"Pangolin", "Mole", "Okapi", "Camel", "Wild cat", "Coyote", "Bison", "African Elephant", | ||
"Aardvark", "Antelope", "Alpine Goat", "Komodo Dragon", "Bearded Dragon", | ||
"Royal Bengal Tiger", "Flying Squirrel", "Emu", "Eagle", "Eel", "Asiatic Lion", | ||
"Armadillo", "Beaver", "Emperor Penguin", "Baboon", "Bat", "Chameleon", "Bull", | ||
"Giant Panda", "Chihuahua", "Orangutan", "Chinchillas", "Hawk", "Iguana", "Ibis", | ||
"Ibex", "King Cobra", "Jellyfish", "Goose", "Walrus", "Seal", "Skink", "Markhor", | ||
"Falcon", "Bull Shark", "Arctic Wolf", "Owl", "Bulbul", "Bobcat", "Guinea Pig", | ||
"Yak", "Reindeer", "Moose", "Puma", "Okapi", "Marten", "Squirrel Monkey", "Caracal" | ||
"Tiger", "Lion", "Elephant", "Leopard", "Panther", "Cheetah", "Wolf", | ||
"Hyena", "Giraffe", "Deer", "Zebra", "Gorilla", "Monkey", "Bear", | ||
"Squirrel", "Kangaroo", "Crocodile", "Panda", "Squirrel", "Mongoose", | ||
"Koala Bear", "Wombat", "Meerkat", "Otter", "Hedgehog", "Raccoon", "Hare", | ||
"Mole", "Rabbit", "Alligator", "Oryx", "Elk", "Badger", "Pangolin", | ||
"Camel", "Coyote", "Bison", "African Elephant", "Antelope", "Alpine Goat", | ||
"Beaver", "Baboon", "Bat", "Giant Panda", "Chihuahua", "Orangutan" | ||
] | ||
|
||
sky = [ | ||
"Eagle", "Hawk", "Bulbul", "Emu", "Flying Squirrel", "Ibis", "Falcon", "Owl", | ||
"Bat", "Chihuahua", "Guinea Pig" | ||
"Eagle", "Hawk", "Emu", "Falcon", "Owl", "Bat", "Chihuahua", "Guinea Pig" | ||
] | ||
|
||
#---------------------------------------- | ||
animals = [random.choice(water), random.choice(wild), random.choice(sky)] | ||
# Randomly choose an animal from each category | ||
|
||
animals = [random.choice(water) , random.choice(wild) , random.choice(sky)] | ||
picked_animal=random.choice(animals) | ||
print("") | ||
|
||
|
||
# Check if a string contains spaces | ||
|
||
def spaces(x): | ||
for i in x: | ||
if i == " ": | ||
return True | ||
return False | ||
|
||
|
||
# Check if the picked animal's name contains spaces | ||
|
||
if spaces(picked_animal)==True: | ||
print ("this name has an *SPACE*") | ||
|
||
|
||
|
||
# Initialize the guessed animal with hidden characters | ||
guessed_animal = animals[0][0] + '*' * (len(animals[0]) - 1) | ||
print("The animals start with the letter", guessed_animal) | ||
|
||
for i in range(3): # Allow three attempts | ||
user_guess = input("Enter your guess: ").capitalize() | ||
|
||
if user_guess == animals[0]: | ||
print(picked_animal) | ||
print("") | ||
|
||
# Determine the category of the picked animal | ||
|
||
if picked_animal in sky: | ||
print("animal is from the sky") | ||
|
||
elif picked_animal in wild: | ||
print("animal is from the wild") | ||
|
||
else: | ||
print("animal is from the water") | ||
|
||
# Initialize the guessed animal with hidden characters | ||
|
||
guessed_animal = picked_animal[0] + '*' * (len(picked_animal) - 1) | ||
print("The animals start with the letter", guessed_animal) | ||
print("") | ||
attempts=0 | ||
for i in range(3): # Allow three attempts | ||
attempts += 1 | ||
user_guess = input("Enter your guess: ").capitalize() | ||
if user_guess == picked_animal: | ||
print("Congratulations! You guessed correctly.") | ||
break | ||
else: | ||
# Reveal one more character if the guess is incorrect | ||
revealed_chars = min((i + 1) + 1, len(animals[0]) - 1) | ||
guessed_animal = animals[0][:revealed_chars] + '*' * (len(animals[0]) - revealed_chars) | ||
print("Incorrect guess. The animals start with the letter", guessed_animal) | ||
revealed_chars = min((i+1) + 1, len(picked_animal)-1) | ||
guessed_animal = picked_animal[:revealed_chars] + '*' * (len(picked_animal) - revealed_chars) | ||
while attempts<3: | ||
print("Incorrect guess. The animals start with the letters", guessed_animal) | ||
break | ||
|
||
print("") | ||
print("The correct animal was:", animals[0]) | ||
print("The correct animal was:", picked_animal) |