Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python program help all steps Step-by-step approach: Step 1 Start by a simple program that asks the user the number of game they want to

python program help all steps image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Step-by-step approach: Step 1 Start by a simple program that asks the user the number of game they want to play, then for each game ask them to enter a choice (no input validation yet). At the end caplay that the game is finished. Sample run: How many gases of flock, Paper Scissors do yoo want to play? 3 Game 1 ** What do you choose (rock or paper or sclssors)?rock Game 2.* What do you choose (rock or paper or scissors)?3 Game 3.* What do you choose (rock or paper or scissors)?black hole End of the gane step 2 Now we add the first validation: make sure that the user enters rock or paper or scissors and nothing else. To be more flewible. you can accept any case (upper or lower) but no toher word, otherwise you ask the user to enter again his choice. The next game does not start until the suer enters a valid choice. Sample run: How many ganes of Rock, Paper Seissors do you want to play? 3 Game 1 * What do you choose (rock or paper or seissors)?rock Game 2 What do you choose (rock or paper or scissors)?3 Choose rock or paper or seissors! What do you choose (rock or paper or scissors)?black hole Choose rock or paper or selssors! What do you choose (rock or paper or scissors)?RoCK Game 3 What do you choose (rock or paper or scissors)?Rock End of the gane Step 3 Now we add the second validation, which is about the number of games: make sure that the numt of games is an integer and positive. You can use try except structure inside a while loop to repeat long as the user does not enter a valid number of games. Sample run: How many games of Rock, Paper Scissors do you want to play? Three This not a valid number of games 1 Number of games should be a positive integer How many games of Rock, Paper Scissors do you want to play? 3 This not a valid number of games! Number of games should be a positive integer How many games of Rock, Paper Scissors do you want to play? 3.5 This not a valid number of games! Number of games should be a positive integer How many games of Rock, Paper Scissors do you want to play? 3 Game 1 *** What do you choose (rock or paper or scissors)?rock Game 2 *** What do you choose (rock or paper or scissors)?rocks Choose rock or paper or scissors! What do you choose (rock or paper or scissors)?ROCK Game 3 ** What do you choose (rock or paper or scissors)?Rock End of the game Step 4 Now it is time to start adding the scoring system. The score should come from a helper function. Create a function rpsGame with a parameter playerChoice that simply returns 1 for now, regardless of the choice of the user. In the main program, each time the user makes a valid choice, call the function and add the output of the function to the score. Since the function simply returns 1 for now, the final score should correspond to the number of games. Display the score after the game ends. Sample run: How many games of Rock, Paper Scissors do you want to play? 4 Game 1 *** What do you choose (rock or paper or scissors)?rock Game 2 *** What do you choose (rock or paper or scissors)?paper Game 3 *** What do you choose (rock or paper or scissors)?scissors Game 4 *** What do you choose (rock or paper or scissors)?Rocks Choose rock or paper or scissors! What do you choose (rock or paper or scissors)?rock End of the game Your score is 4 Step 5 Before being able to compute a real score, we need first to coded the computer choice. The computer choice is a random choice between 0 (rock), 1 (paper), or 2 (scissors). The random choice between 0 and 2 can be done using the random module and the function randint. Of course the computer should display what it chose to check that it is not cheating. One way to do so, is create a global constant, which is a list containt the three choices ["rock", "paper", "scissors"]. Then based on the number chosen by the computer display the element from the list at the index chosen by the computer. All of this should happen in the function, the scoring system does not change yet, the function still returns 1 but it shows what the computer chose in each game. Sample run: How many games of Rock, Paper Scissors do you want to play? 4 Game 1 *** What do you choose (rock or paper or scissors) ?rock Computer chose rock *** Game 2 *** What do you choose (rock or paper or scissors)?rock Computer chose paper Game 3 *** What do you choose (rock or paper or scissors)?rock Computer chose rock *** Game 4 *** What do you choose (rock or paper or scissors)?rock Computer chose scissors End of the game Your score is 4 Soep 6 numbers. to a te, ahich corsecipench to a icare of 1. hwaman: - Ir bet dreipise is 5 at is a tie and the ware in 1 Samplenn How eary eenes of hick, Fieer Scivars af yow went to ytayt sin This sot a xilis nuter of guesi Munter of cuses showat te a jesation integer ther any gubes af Aeck, foser Selisers den yes mont to atap? of wer Gane 1 *k What on ynu these (rock or saser ar stiwars) lrack Cosputer chose seicsen Ye. win tids Finel *N Game I ** What do yeu those frock or pies ar stictarsilinacks Choble pock ar paper or itelisorat What do you teose (rock or pecer ar scinarsine kacx Casputar chase saper Conquter why this romel: ten dan 1 kik what do you choos (rosk or paper ar meiksers) Aect Conouter chese it lispes voe uin this rounel ove Cian 4 wn that ia ymu cheose (rase or paser mo silmors) rock Conputer choine papor Coeputer wink thas riagd! *c" 6a=5 kN what do you choose (rose or paper ar sci ewors) ilpack Conquter chase scissues rou man thit rauna! ove Game in tov computar chaie rack Thls penet is a tiene End at the rase Your "corn is ie

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions