Question: Using python write the code using these instructions: 2 Ways to do this: 1 . Put a for count in range ( 5 ) :
Using python write the code using these instructions: Ways to do this:
Put a for count in range: loop around your entire code
Make your code a function that runs one simulation and returns the years in jail of
partner A and B in an arraylist cleaner imo
Make partnerAcount and partnerBcount variable at the top
or if you do the function before you call the function
In your ifelifelse statements add the corresponding years to partnerAcount
and partnerBcount.
the if statements where it prints the You both do yearsYoure released...
To find the averages, divide the counts by
Later, this will become a variable, so make a variable, count and put it in
rangecount and do partnerAcountcount
If you hardcoded trials, you should change that to a count variable
At the very top, call input and ask how many trials they want.
Or above the function call if you used a function
count intinputHow many trials should be simulated
Make a while statement that checks that the user entered a number
between and
Inside the while statement, if they didnt enter a valid number:
Print Please enter a number between and
then ask again for a number using input and store that into the count variable.
Copy and paste the menu text from the canvas page and print that out
Make a strategy variable partnerAStrat for player A and then use input to
get user input for that strategy.
Check if its not between and using a while loop. Something like
whilepartnerAStrat or partnerAStrat :
Inside the while loop:
Print Must enter a number between and
Please try again
Ask for another input
Repeat the step above for player B
Once you have partnerAStrat and partnerBStrat...
Where you declared partnerAChoice and partnerBChoice, make an ifelifelse ladder
that sets the choices to or randint
If you did a function approach, you might have to pass in extra arguments for the
strategy in your function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
