From 7bbe2fbe4114db2c39f349b7342ed117dae247b8 Mon Sep 17 00:00:00 2001 From: Sachin Vinayak Dabhade <78628027+SachinDabhade@users.noreply.github.com> Date: Sat, 15 Oct 2022 13:47:27 +0530 Subject: [PATCH 1/5] Added Snake, Water and Gun Game in python --- .../Snake_Water_Gun_Game.py | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py diff --git a/Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py b/Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py new file mode 100644 index 0000000..b3f3e75 --- /dev/null +++ b/Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py @@ -0,0 +1,115 @@ +# ******************************** This is a snake, water, gun game ************************************ + +# Importing Libraries +from datetime import datetime +import random +import time + +# Welcoming the user... +print("\nWelcome to SNAKE, WATER and GUN game by Sachin Dabhade\n") +name = input("Enter your name: \n") +print("\nHello " + name.capitalize() + "! Best of Luck!\n") +time.sleep(1) +print("The game is about to start!\n Let's play and win!\n\n") +time.sleep(1) + +# This will check that what input is given by user/human +def human_input(): + if x == "s": + return "Snake" + elif x == "w": + return "Water" + else: + return "Gun" + +# This will check that what input is choose by the computer +def computer_input(): + if e == "s": + return "Snake" + elif e == "w": + return "Water" + else: + return "Gun" + +# This is body of the program when the user wins +def body(): + print(f"Your guess is {human_input()} and computer guess is {computer_input()}") + print("Congratulation.. You Won") + print(f"Your points are {human_points} and computer points are {computer_points}") + +# This is the 2nd body of program when the computer wins +def body_2(): + print(f"Your guess is {human_input()} and computer guess is {computer_input()}") + print("Sorry.. Computer Won") + print(f"Computer points are {computer_points} and human points are {human_points}") + +# This is the best part of program that will record the starting time of program and the result of program +def record(winner, points, result): + with open("record.txt", "a") as f: + f.write(f"The SNAKE, WATER and GUN game is played by {name} on {datetime.now()} and {winner} {result} by {points} points\n") + +# This is the main programme... +if __name__ == '__main__': + + elements = ("s", "w", "g") + print("\t\t\t\t\tSnake, Water and Gun Game...\n || \'S\' for snake || \'W\' for water || \'G\' for gun ||\n") + + # users necessary elements + no_of_choises = 10 + choises = 0 + human_points = 0 + computer_points = 0 + + # while loop is applied + while choises < no_of_choises: + inp = input("Please.. Enter your choice : ") + e = random.choice(elements) + x = inp.lower() + + if x == e: + print("This is draw because of same choises...Please try again..") + print(f"Your guess is {human_input()} and computer guess is {computer_input()}") + print(f"Your points are {human_points} and computer points are {computer_points}") + + elif x == "s" and e == "w": + human_points = human_points + 1 + body() + + elif x == "w" and e == "g": + human_points = human_points + 1 + body() + + elif x == "g" and e == "s": + human_points = human_points + 1 + body() + + elif x == "s" and e == "g": + computer_points = computer_points + 1 + body_2() + + elif x == "g" and e == "w": + computer_points = computer_points + 1 + body_2() + + elif x == "w" and e == "s": + computer_points = computer_points + 1 + body_2() + + else: + print("Invalid input\nPlease check your input") + + choises = choises + 1 + print(f"{no_of_choises - choises} chances is left out off {no_of_choises} \n\n") + + print("Game Over...!") + + if computer_points > human_points: + print(f"Sorry You have lost the game by {computer_points - human_points} points") + record(name, computer_points-human_points, 'lost') + + elif computer_points < human_points: + print(f"Congratulation You have Won the game by {human_points - computer_points} points") + record(name, human_points-computer_points, 'won') + + else: + print("Sorry...Both have same points...So this is a tie match") \ No newline at end of file From 8b12936140e3b0c5ec6170f9551db22785a6ee6b Mon Sep 17 00:00:00 2001 From: Sachin Vinayak Dabhade <78628027+SachinDabhade@users.noreply.github.com> Date: Sat, 15 Oct 2022 13:50:10 +0530 Subject: [PATCH 2/5] Update and rename Snake_Water_Gun_Game.py to Month_Guessing_Game.py --- .../Month_Guessing_Game.py | 111 +++++++++++++++++ .../Snake_Water_Gun_Game.py | 115 ------------------ 2 files changed, 111 insertions(+), 115 deletions(-) create mode 100644 Projects/Snake Water and Gun Game/Month_Guessing_Game.py delete mode 100644 Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py diff --git a/Projects/Snake Water and Gun Game/Month_Guessing_Game.py b/Projects/Snake Water and Gun Game/Month_Guessing_Game.py new file mode 100644 index 0000000..304d24d --- /dev/null +++ b/Projects/Snake Water and Gun Game/Month_Guessing_Game.py @@ -0,0 +1,111 @@ +# ******************** Month Guessing Game *************************** + +# Importing library +from datetime import datetime +import random +import time + +# Initial Steps to invite in the game: +print("\nWelcome to MONTH GUESSING game by Sachin Dabhade\n") +name = input("Enter your name: ") +print("\nHello " + name.capitalize() + "! Best of Luck!") +time.sleep(1) +print("\nThe game is about to start!\n Let's play and win!\n\n") +time.sleep(1) + +# This will record all the activities in my game +def record(): + with open("record.txt", "a") as f: + f.write(f"The MONTH GUESSING game is played by {name.upper()} on {datetime.now()}\n") +record() + +# This will shown after winning +def win(): + print("\nCongratulation...! You won...!") + print("You are lucky that you did not hanged to the hanger") + print(" _____ \n" + " | |\n" + " | |\n" + " | \n" + " | O \n" + " | /|\ \n" + " | / \ \n" + "__|__ -----\n") + print( + "\nThanks for playing with us..! We expect you have enjoy our game...!\nSee you again.. Till then take care...!") + exit() + +if __name__ == '__main__': + # The parameters we require to execute the game: + words_to_guess = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", + "november", "december"] + word = random.choice(words_to_guess) + length = len(word) + display = '_ ' * length + limit = 5 + attempt = 0 + score = 0 + + while limit > attempt: + guess = input("You have to guess the month of year:" + display + " Enter your guess: \n") + + if guess.lower() == word: + score = score + 1 + win() + + else: + attempt += 1 + print('\n') + if attempt == 1: + print("You are going to die...!\n") + print(" | \n" + " | \n" + " | \n" + " | \n" + " | \n" + "__|__\n") + elif attempt == 2: + print("You are on the way to die...!\n") + print(" _____ \n" + " | \n" + " | \n" + " | \n" + " | \n" + " | \n" + " | \n" + "__|__\n") + elif attempt == 3: + print("You are few step away to die...!\n") + print(" _____ \n" + " | | \n" + " | |\n" + " | | \n" + " | \n" + " | \n" + " | \n" + "__|__\n") + elif attempt == 4: + print("You are just in front of hanger...!\n") + print(" _____ \n" + " | | \n" + " | |\n" + " | | \n" + " | O \n" + " | \n" + " | \n" + "__|__\n") + elif attempt == 5: + print("You are hanged on and you are dead...!\n") + print(" _____ \n" + " | | \n" + " | |\n" + " | | \n" + " | O \n" + " | /|\ \n" + " | / \ \n" + "__|__\n") + print("Wrong guess. You are hanged!!!\n") + print("The word was:", word) + + print(f"your score is {score} and you have {limit - attempt} chances remaining..!\n\n") + continue diff --git a/Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py b/Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py deleted file mode 100644 index b3f3e75..0000000 --- a/Projects/Snake Water and Gun Game/Snake_Water_Gun_Game.py +++ /dev/null @@ -1,115 +0,0 @@ -# ******************************** This is a snake, water, gun game ************************************ - -# Importing Libraries -from datetime import datetime -import random -import time - -# Welcoming the user... -print("\nWelcome to SNAKE, WATER and GUN game by Sachin Dabhade\n") -name = input("Enter your name: \n") -print("\nHello " + name.capitalize() + "! Best of Luck!\n") -time.sleep(1) -print("The game is about to start!\n Let's play and win!\n\n") -time.sleep(1) - -# This will check that what input is given by user/human -def human_input(): - if x == "s": - return "Snake" - elif x == "w": - return "Water" - else: - return "Gun" - -# This will check that what input is choose by the computer -def computer_input(): - if e == "s": - return "Snake" - elif e == "w": - return "Water" - else: - return "Gun" - -# This is body of the program when the user wins -def body(): - print(f"Your guess is {human_input()} and computer guess is {computer_input()}") - print("Congratulation.. You Won") - print(f"Your points are {human_points} and computer points are {computer_points}") - -# This is the 2nd body of program when the computer wins -def body_2(): - print(f"Your guess is {human_input()} and computer guess is {computer_input()}") - print("Sorry.. Computer Won") - print(f"Computer points are {computer_points} and human points are {human_points}") - -# This is the best part of program that will record the starting time of program and the result of program -def record(winner, points, result): - with open("record.txt", "a") as f: - f.write(f"The SNAKE, WATER and GUN game is played by {name} on {datetime.now()} and {winner} {result} by {points} points\n") - -# This is the main programme... -if __name__ == '__main__': - - elements = ("s", "w", "g") - print("\t\t\t\t\tSnake, Water and Gun Game...\n || \'S\' for snake || \'W\' for water || \'G\' for gun ||\n") - - # users necessary elements - no_of_choises = 10 - choises = 0 - human_points = 0 - computer_points = 0 - - # while loop is applied - while choises < no_of_choises: - inp = input("Please.. Enter your choice : ") - e = random.choice(elements) - x = inp.lower() - - if x == e: - print("This is draw because of same choises...Please try again..") - print(f"Your guess is {human_input()} and computer guess is {computer_input()}") - print(f"Your points are {human_points} and computer points are {computer_points}") - - elif x == "s" and e == "w": - human_points = human_points + 1 - body() - - elif x == "w" and e == "g": - human_points = human_points + 1 - body() - - elif x == "g" and e == "s": - human_points = human_points + 1 - body() - - elif x == "s" and e == "g": - computer_points = computer_points + 1 - body_2() - - elif x == "g" and e == "w": - computer_points = computer_points + 1 - body_2() - - elif x == "w" and e == "s": - computer_points = computer_points + 1 - body_2() - - else: - print("Invalid input\nPlease check your input") - - choises = choises + 1 - print(f"{no_of_choises - choises} chances is left out off {no_of_choises} \n\n") - - print("Game Over...!") - - if computer_points > human_points: - print(f"Sorry You have lost the game by {computer_points - human_points} points") - record(name, computer_points-human_points, 'lost') - - elif computer_points < human_points: - print(f"Congratulation You have Won the game by {human_points - computer_points} points") - record(name, human_points-computer_points, 'won') - - else: - print("Sorry...Both have same points...So this is a tie match") \ No newline at end of file From 03c186665f1c3aeb081b2b343763075df2bd1f09 Mon Sep 17 00:00:00 2001 From: Sachin Vinayak Dabhade <78628027+SachinDabhade@users.noreply.github.com> Date: Sun, 23 Oct 2022 11:21:47 +0530 Subject: [PATCH 3/5] Delete Projects/Snake Water and Gun Game directory --- .../Month_Guessing_Game.py | 111 ------------------ 1 file changed, 111 deletions(-) delete mode 100644 Projects/Snake Water and Gun Game/Month_Guessing_Game.py diff --git a/Projects/Snake Water and Gun Game/Month_Guessing_Game.py b/Projects/Snake Water and Gun Game/Month_Guessing_Game.py deleted file mode 100644 index 304d24d..0000000 --- a/Projects/Snake Water and Gun Game/Month_Guessing_Game.py +++ /dev/null @@ -1,111 +0,0 @@ -# ******************** Month Guessing Game *************************** - -# Importing library -from datetime import datetime -import random -import time - -# Initial Steps to invite in the game: -print("\nWelcome to MONTH GUESSING game by Sachin Dabhade\n") -name = input("Enter your name: ") -print("\nHello " + name.capitalize() + "! Best of Luck!") -time.sleep(1) -print("\nThe game is about to start!\n Let's play and win!\n\n") -time.sleep(1) - -# This will record all the activities in my game -def record(): - with open("record.txt", "a") as f: - f.write(f"The MONTH GUESSING game is played by {name.upper()} on {datetime.now()}\n") -record() - -# This will shown after winning -def win(): - print("\nCongratulation...! You won...!") - print("You are lucky that you did not hanged to the hanger") - print(" _____ \n" - " | |\n" - " | |\n" - " | \n" - " | O \n" - " | /|\ \n" - " | / \ \n" - "__|__ -----\n") - print( - "\nThanks for playing with us..! We expect you have enjoy our game...!\nSee you again.. Till then take care...!") - exit() - -if __name__ == '__main__': - # The parameters we require to execute the game: - words_to_guess = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", - "november", "december"] - word = random.choice(words_to_guess) - length = len(word) - display = '_ ' * length - limit = 5 - attempt = 0 - score = 0 - - while limit > attempt: - guess = input("You have to guess the month of year:" + display + " Enter your guess: \n") - - if guess.lower() == word: - score = score + 1 - win() - - else: - attempt += 1 - print('\n') - if attempt == 1: - print("You are going to die...!\n") - print(" | \n" - " | \n" - " | \n" - " | \n" - " | \n" - "__|__\n") - elif attempt == 2: - print("You are on the way to die...!\n") - print(" _____ \n" - " | \n" - " | \n" - " | \n" - " | \n" - " | \n" - " | \n" - "__|__\n") - elif attempt == 3: - print("You are few step away to die...!\n") - print(" _____ \n" - " | | \n" - " | |\n" - " | | \n" - " | \n" - " | \n" - " | \n" - "__|__\n") - elif attempt == 4: - print("You are just in front of hanger...!\n") - print(" _____ \n" - " | | \n" - " | |\n" - " | | \n" - " | O \n" - " | \n" - " | \n" - "__|__\n") - elif attempt == 5: - print("You are hanged on and you are dead...!\n") - print(" _____ \n" - " | | \n" - " | |\n" - " | | \n" - " | O \n" - " | /|\ \n" - " | / \ \n" - "__|__\n") - print("Wrong guess. You are hanged!!!\n") - print("The word was:", word) - - print(f"your score is {score} and you have {limit - attempt} chances remaining..!\n\n") - continue From bf61d2204fc9ae1bf5bece937b1a23ab66fa35f3 Mon Sep 17 00:00:00 2001 From: Sachin Vinayak Dabhade <78628027+SachinDabhade@users.noreply.github.com> Date: Sun, 23 Oct 2022 11:23:25 +0530 Subject: [PATCH 4/5] Add files via upload --- .../Snake Water and Gun Game/SnakeWaterGun.py | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Projects/Snake Water and Gun Game/SnakeWaterGun.py diff --git a/Projects/Snake Water and Gun Game/SnakeWaterGun.py b/Projects/Snake Water and Gun Game/SnakeWaterGun.py new file mode 100644 index 0000000..b3f3e75 --- /dev/null +++ b/Projects/Snake Water and Gun Game/SnakeWaterGun.py @@ -0,0 +1,115 @@ +# ******************************** This is a snake, water, gun game ************************************ + +# Importing Libraries +from datetime import datetime +import random +import time + +# Welcoming the user... +print("\nWelcome to SNAKE, WATER and GUN game by Sachin Dabhade\n") +name = input("Enter your name: \n") +print("\nHello " + name.capitalize() + "! Best of Luck!\n") +time.sleep(1) +print("The game is about to start!\n Let's play and win!\n\n") +time.sleep(1) + +# This will check that what input is given by user/human +def human_input(): + if x == "s": + return "Snake" + elif x == "w": + return "Water" + else: + return "Gun" + +# This will check that what input is choose by the computer +def computer_input(): + if e == "s": + return "Snake" + elif e == "w": + return "Water" + else: + return "Gun" + +# This is body of the program when the user wins +def body(): + print(f"Your guess is {human_input()} and computer guess is {computer_input()}") + print("Congratulation.. You Won") + print(f"Your points are {human_points} and computer points are {computer_points}") + +# This is the 2nd body of program when the computer wins +def body_2(): + print(f"Your guess is {human_input()} and computer guess is {computer_input()}") + print("Sorry.. Computer Won") + print(f"Computer points are {computer_points} and human points are {human_points}") + +# This is the best part of program that will record the starting time of program and the result of program +def record(winner, points, result): + with open("record.txt", "a") as f: + f.write(f"The SNAKE, WATER and GUN game is played by {name} on {datetime.now()} and {winner} {result} by {points} points\n") + +# This is the main programme... +if __name__ == '__main__': + + elements = ("s", "w", "g") + print("\t\t\t\t\tSnake, Water and Gun Game...\n || \'S\' for snake || \'W\' for water || \'G\' for gun ||\n") + + # users necessary elements + no_of_choises = 10 + choises = 0 + human_points = 0 + computer_points = 0 + + # while loop is applied + while choises < no_of_choises: + inp = input("Please.. Enter your choice : ") + e = random.choice(elements) + x = inp.lower() + + if x == e: + print("This is draw because of same choises...Please try again..") + print(f"Your guess is {human_input()} and computer guess is {computer_input()}") + print(f"Your points are {human_points} and computer points are {computer_points}") + + elif x == "s" and e == "w": + human_points = human_points + 1 + body() + + elif x == "w" and e == "g": + human_points = human_points + 1 + body() + + elif x == "g" and e == "s": + human_points = human_points + 1 + body() + + elif x == "s" and e == "g": + computer_points = computer_points + 1 + body_2() + + elif x == "g" and e == "w": + computer_points = computer_points + 1 + body_2() + + elif x == "w" and e == "s": + computer_points = computer_points + 1 + body_2() + + else: + print("Invalid input\nPlease check your input") + + choises = choises + 1 + print(f"{no_of_choises - choises} chances is left out off {no_of_choises} \n\n") + + print("Game Over...!") + + if computer_points > human_points: + print(f"Sorry You have lost the game by {computer_points - human_points} points") + record(name, computer_points-human_points, 'lost') + + elif computer_points < human_points: + print(f"Congratulation You have Won the game by {human_points - computer_points} points") + record(name, human_points-computer_points, 'won') + + else: + print("Sorry...Both have same points...So this is a tie match") \ No newline at end of file From 258979727c576b213ba737fd06aeb990e14e1d38 Mon Sep 17 00:00:00 2001 From: Sachin Vinayak Dabhade <78628027+SachinDabhade@users.noreply.github.com> Date: Sun, 23 Oct 2022 11:37:12 +0530 Subject: [PATCH 5/5] Rename SnakeWaterGun.py to snakeWaterGun.py --- .../{SnakeWaterGun.py => snakeWaterGun.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Projects/Snake Water and Gun Game/{SnakeWaterGun.py => snakeWaterGun.py} (96%) diff --git a/Projects/Snake Water and Gun Game/SnakeWaterGun.py b/Projects/Snake Water and Gun Game/snakeWaterGun.py similarity index 96% rename from Projects/Snake Water and Gun Game/SnakeWaterGun.py rename to Projects/Snake Water and Gun Game/snakeWaterGun.py index b3f3e75..6ae27b7 100644 --- a/Projects/Snake Water and Gun Game/SnakeWaterGun.py +++ b/Projects/Snake Water and Gun Game/snakeWaterGun.py @@ -112,4 +112,4 @@ def record(winner, points, result): record(name, human_points-computer_points, 'won') else: - print("Sorry...Both have same points...So this is a tie match") \ No newline at end of file + print("Sorry...Both have same points...So this is a tie match")