From be157657dcf12be86a8e662dcdc654e06f4f5f4f Mon Sep 17 00:00:00 2001 From: AVS1508 Date: Sun, 2 Aug 2020 18:42:03 +0530 Subject: [PATCH] Added Python program --- .vscode/settings.json | 3 ++ main.py | 92 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 main.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..de288e1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.formatting.provider": "black" +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..d378fea --- /dev/null +++ b/main.py @@ -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()