From db025988d8e2cf9954bb8d6f3fb6edd0058c410f Mon Sep 17 00:00:00 2001 From: Dwarakesh T P Date: Sat, 21 Aug 2021 21:49:20 +0530 Subject: [PATCH 1/4] Code fix to retain the same computer_number through the game --- Number Guessing Game/numberGuessingGame.py | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Number Guessing Game/numberGuessingGame.py b/Number Guessing Game/numberGuessingGame.py index f8777f87..eaabf37d 100644 --- a/Number Guessing Game/numberGuessingGame.py +++ b/Number Guessing Game/numberGuessingGame.py @@ -1,3 +1,4 @@ +# coding=utf-8 import random # random module is a built-in module to generate pseudo-random variables @@ -19,10 +20,10 @@ def startGame(): displayGameplay = display_gameplay() # make a list of the possible inputs # to start or end the game - POSSIBLE_RESPONSES = ['Y','YES','N','NO','EXIT'] + possible_responses = ['Y','YES','N','NO','EXIT'] # get user's response user_response = input('\nStart game? (yes/no): ').strip().upper() - while user_response not in POSSIBLE_RESPONSES: + while user_response not in possible_responses: print('\nInvalid Input!') user_response = input('\nStart game? (yes/no): ').strip().upper() else: return user_response @@ -36,13 +37,15 @@ def game(): play_game = startGame() # assign the number of trials the user has to a variable number_of_trials = 7 + # initialise new_game to true + new_game = True while play_game == 'YES' or play_game == 'Y': # make a list that contains all the # numbers a user can guess - ACCEPTED_NUMBER_PICKS = [str(i) for i in range(1,11)] + accepted_number_picks = [str(i) for i in range(1,11)] # get user's number user_input = input('\nGuess a number between the range of 1-10: ').strip().upper() - while user_input not in ACCEPTED_NUMBER_PICKS and user_input != 'EXIT' : + while user_input not in accepted_number_picks and user_input != 'EXIT' : print('Invalid Input!') user_input = input('\nGuess a valid number between the range of 1-10: ').strip().upper() if user_input == 'EXIT': @@ -51,7 +54,10 @@ def game(): else: # generate a random number in the range 1-10 # and assign it to a variable - computer_number = random.randint(1,10) + # check if new_game, if true generate new computer_number else don't + if new_game: + computer_number = random.randint(1,10) + new_game = False user_input = int(user_input) if user_input < computer_number: number_of_trials -= 1 @@ -60,7 +66,7 @@ def game(): print(f'You\'ve {number_of_trials} trial(s) left') play_game = input('\nGuess again? (yes/no): ').strip().upper() else: - print(F'\nGame over!, you\'ve 0 trial left..try harder next time 😉') + print('\nGame over!, you\'ve 0 trial left..try harder next time 😉') break elif user_input > computer_number: number_of_trials -= 1 @@ -69,7 +75,7 @@ def game(): print(f'You\'ve {number_of_trials} trial(s) left') play_game = input('\nGuess again? (yes/no): ').strip().upper() else: - print(F'\nGame over!, you\'ve 0 trial left..try harder next time 😉') + print('\nGame over!, you\'ve 0 trial left..try harder next time 😉') break elif user_input == computer_number: number_of_trials -= 1 @@ -77,6 +83,9 @@ def game(): play_game = input('\nDo you wish to play again? (yes/no): ').strip().upper() # if the user wishes to play again, assign # the number of trials the user has to a variable - number_of_trials = 7 + number_of_trials = 7 + # start a new game + new_game = True -game() \ No newline at end of file +if __name__ == '__main__': + game() \ No newline at end of file From 9246375713627ad330708c4762c69d5207305b18 Mon Sep 17 00:00:00 2001 From: Dwarakesh T P Date: Sat, 21 Aug 2021 22:02:37 +0530 Subject: [PATCH 2/4] Undo main --- Number Guessing Game/numberGuessingGame.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Number Guessing Game/numberGuessingGame.py b/Number Guessing Game/numberGuessingGame.py index eaabf37d..9495c645 100644 --- a/Number Guessing Game/numberGuessingGame.py +++ b/Number Guessing Game/numberGuessingGame.py @@ -87,5 +87,4 @@ def game(): # start a new game new_game = True -if __name__ == '__main__': - game() \ No newline at end of file +game() \ No newline at end of file From 856f460adcd6bb2d77213a554aa73c530867ff44 Mon Sep 17 00:00:00 2001 From: mannuel25 Date: Sat, 11 Sep 2021 13:56:44 +0100 Subject: [PATCH 3/4] updated README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 48033e96..8f04085e 100644 --- a/README.md +++ b/README.md @@ -81,3 +81,5 @@ The contribution guidelines are as per the guide [HERE](https://github.com/larym | 38 | [Number Guessing Game](https://github.com/Mannuel25/Python-project-Scripts/tree/main/Number%20Guessing%20Game) | [Emmanuel Tanimowo](https://github.com/Mannuel25) | | 39 | [Web Dev with python Flask](https://github.com/deepaksaipendyala/Python-project-Scripts/tree/main/Web%20Dev%20with%20Flask) | [Deepak Sai Pendyala](https://github.com/deepaksaipendyala) | | 40 | [password breach checker](https://github.com/deepaksaipendyala/Python-project-Scripts/tree/main/passwordbreachchecker) | [Deepak Sai Pendyala](https://github.com/deepaksaipendyala) | +| 41 | [Audio Book](https://github.com/Mannuel25/Python-project-Scripts/tree/main/AudioBuk) | [Lary Mak](https://github.com/larymak) | +| 42 | [Geocoding Google API](https://github.com/Mannuel25/Python-project-Scripts/tree/main/Geocoding%20Google%20API) | [Sherief Elsowiny](https://github.com/elsowiny) | \ No newline at end of file From 6a7a1ca604acee69d9c1a5e6563d20c8f08c0a05 Mon Sep 17 00:00:00 2001 From: mannuel25 Date: Sat, 11 Sep 2021 14:19:55 +0100 Subject: [PATCH 4/4] added new projects to README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f04085e..6897a790 100644 --- a/README.md +++ b/README.md @@ -82,4 +82,6 @@ The contribution guidelines are as per the guide [HERE](https://github.com/larym | 39 | [Web Dev with python Flask](https://github.com/deepaksaipendyala/Python-project-Scripts/tree/main/Web%20Dev%20with%20Flask) | [Deepak Sai Pendyala](https://github.com/deepaksaipendyala) | | 40 | [password breach checker](https://github.com/deepaksaipendyala/Python-project-Scripts/tree/main/passwordbreachchecker) | [Deepak Sai Pendyala](https://github.com/deepaksaipendyala) | | 41 | [Audio Book](https://github.com/Mannuel25/Python-project-Scripts/tree/main/AudioBuk) | [Lary Mak](https://github.com/larymak) | -| 42 | [Geocoding Google API](https://github.com/Mannuel25/Python-project-Scripts/tree/main/Geocoding%20Google%20API) | [Sherief Elsowiny](https://github.com/elsowiny) | \ No newline at end of file +| 42 | [Geocoding Google API](https://github.com/Mannuel25/Python-project-Scripts/tree/main/Geocoding%20Google%20API) | [Sherief Elsowiny](https://github.com/elsowiny) | +| 43 | [News Article Scraping](https://github.com/Mannuel25/Python-project-Scripts/tree/main/News_Article_Scraping) | [SasiKalyan](https://github.com/KanakamSasikalyan) | +| 44 | [Sudoku Solver](https://github.com/Mannuel25/Python-project-Scripts/tree/main/SudokuSolver) | [Ruben Grande Muñoz](https://github.com/RgrMz) |