Skip to content

Commit

Permalink
Added Python program
Browse files Browse the repository at this point in the history
  • Loading branch information
AVS1508 committed Aug 2, 2020
1 parent 81f281a commit be15765
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.formatting.provider": "black"
}
92 changes: 92 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Project Title : Hollywood - A Movie Guessing Game
# Version : 1.0
# Developed By : Aditya Vikram Singh

import math, random


class Hollywood:

moviesList = [
"INTERSTELLAR",
"ARMAGEDDON",
"INCEPTION",
"PLANET OF THE APES",
"VAN HELSING",
"IRON MAN",
"PHANTOM THREAD",
"LES MISERABLES",
"THE REVENANT",
"TITANIC",
"THE DARK KNIGHT",
"ROCKY",
"JUSTICE LEAGUE",
"STAR WARS",
"THE GODFATHER",
"WONDER WOMAN",
"COCO",
"THE AVENGERS",
"AVATAR",
"BRAVEHEART",
"JURASSIC PARK",
"MAN OF STEEL",
"THE MATRIX",
"LOGAN",
"FORREST GUMP",
]

def SelectRandomMovie():
return Hollywood.moviesList[math.floor(random.randint(0, 24))]

def CreateDummyMovieAndEncode(movie):
movieCopy = list(movie)
for i in range(len(movieCopy)):
if movieCopy[i] not in ["A", "E", "I", "O", "U", " "]:
movieCopy[i] = "*"
return "".join(movieCopy)

def FillOrSlash(movie, current):
chances = 9
currentCopy = list(current)
while chances > 0:
while True:
print("Guess a non-vowel alphabet: ")
inp = input()
if inp not in ["A", "E", "I", "O", "U", " "]:
break
found = False
for i in range(len(movie)):
if inp == movie[i]:
currentCopy[i] = inp
found = True
if movie == "".join(currentCopy):
chances = 0
print(movie)
print("Congratulations! You guessed the movie.")
elif found:
print("Good guess!")
print("".join(currentCopy))
else:
chances = chances - 1
print("Character not present!")
print("".join(currentCopy))
print("Chances remaining: ", chances)
if movie != "".join(currentCopy):
print("Chances are over, sorry! Better luck next time!")
print("The movie was: ", movie)


def main():
print("Hello! Let's play a game of HOLLYWOOD - a movie guessing game! ")
toggle = "Y"
while toggle != "N":
movie = Hollywood.SelectRandomMovie()
dummy = Hollywood.CreateDummyMovieAndEncode(movie)
print(dummy)
Hollywood.FillOrSlash(movie, dummy)
print("Do you want to play another game (Y/N)?")
toggle = input()


if __name__ == "__main__":
main()

0 comments on commit be15765

Please sign in to comment.