Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi this is Python programming Rock, Paper, and Scissor game When the program beg

ID: 3667847 • Letter: H

Question

Hi this is Python programming

Rock, Paper, and Scissor game

When the program begins, a random integer number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If thenumber is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the computer’s choice yet)

The user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard. You can use a menu if you prefer)

The computer’s choice is displayed.

A winner is selected according to the following rules:

If one player chooses rock and the other player choosesscissors, then rock wins.

If one player chooses scissors and the other player chooses paper, then scissors wins.

If one player chooses paper and the other player chooses rock, then paper wins.

If both players make the same choice, the game must be played again to determine the winner.

After a winner is selected, the program asks if the user wants to repeat the game. If the answer is yes, restart the game from step 1.

Divide the program into functions that perform each major task.

My little experience I got these codes

__author__ = 'mash4peace'
import random
def main ():
    program = game_program()
def game_program():
    user_input = str(input('Please type your choice : '))

    if user_input == 'Rock' or user_input == 'rock': print('Your choice is ', user_input)
    elif user_input == 'Scissor' or user_input == 'scissor': print('Your choice is ', user_input)
    elif user_input == 'Paper' or user_input == 'paper' : print('Your choice is', user_input)
    else:
        print("Huh HUH Huh, Error msg")
        user_input = str(input('Please type your choice : '))

    computer_selection = random.randint(1, 3)
    if computer_selection == 1:
        print('Computer choice is Rock')
    elif computer_selection == 2 :
        print('Computer choice is Paper')
    elif computer_selection == 3:
         print('Computer choice is Scissor')

    winner = winnser_selection(user_input, computer_selection)
def winnser_selection(user_input, computer_selection):

    if (user_input == 'Rock' or user_input == 'rock'):
        if(computer_selection == 'Paper'):
            print('Conputer Won !!!!')
        else:
            print("User won !!!")
    elif (user_input == "Paper" or user_input == 'paper'):
        if (computer_selection == "Rock"):
            print("User won!")
        else:
            print("Computer wins!")
    elif (user_input == 'Scissor' or user_input == 'scissor'):
        if (computer_selection == 'Rock'):
            print('Computer won !!!')
        else:
            print('User won !!!')






main()

Explanation / Answer

import random def gather_Information(): #User information: user = int(input("scissor(0), rock(1), paper(2): ")) npc = random.randint(0,2) return user, npc def calculate_Winner(user, npc): if user == 0 and npc == 0: print( "The computer is scissor. You are scissor too. It is a draw.") return 0 elif user == 0 and npc == 1: print( "The computer is rock. You are scissor. You lose") return -1 elif user == 0 and npc == 2: print( "The computer is paper. You are scissor. You win (;") return 1 elif user == 1 and npc == 0: print( "The computer is scissor. You are rock. You win") return 1 elif user == 1 and npc == 1: print( "The computer is rock. You are rock. It is a draw.") return 0 elif user == 1 and npc == 2: print( "The computer is paper. You are rock. You lose.") return -1 elif user == 2 and npc == 0: print( "The computer is scissor. You are paper. You lose") return -1 elif user == 2 and npc == 1: print( "The computer is rock. You are paper. You win") return 1 elif user == 2 and npc == 2: print( "The computer is paper. You are paper too. Draw") return 0 def no_winner(user_score,npc_score): if user_score == 3: print("Game over User wins!") return False elif npc_score == 3: print("Game over NPC wins!") return False else: return True def main(): user_score = 0 npc_score = 0 score = 0 while no_winner(user_score,npc_score) == True: score = 0 user, npc = gather_Information() score = calculate_Winner(user, npc) if score == 1: user_score += 1 elif score == -1: npc_score +=1 if __name__ == '__main__': main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote