Question: use a Python list to replace the 11 variables for the accumulators and the 11 separate print statements: import random def rolldice(): dice1 = random.randint(1,

use a Python list to replace the 11 variables for the accumulators and the 11 separate print statements:

import random def rolldice(): dice1 = random.randint(1, 6) dice2 = random.randint(1, 6) return dice1 + dice2 count2 = 0 count3 = 0 count4 = 0 count5 = 0 count6 = 0 count7 = 0 count8 = 0 count9 = 0 count10 = 0 count11 = 0 count12 = 0 for i in range(1, 10001): rollsum = rolldice() if rollsum == 2: count2 += 1 elif rollsum == 3: count3 += 1 elif rollsum == 4: count4 += 1 elif rollsum == 5: count5 += 1 elif rollsum == 6: count6 += 1 elif rollsum == 7: count7 += 1 elif rollsum == 8: count8 += 1 elif rollsum == 9: count9 += 1 elif rollsum == 10: count10 += 1 elif rollsum == 11: count11 += 1 elif rollsum == 12: count12 += 1 print("Percentage of 2s:", (count2/10000)*100, "%") print("Percentage of 3s:", (count3/10000)*100, "%") print("Percentage of 4s:", (count4/10000)*100, "%") print("Percentage of 5s:", (count5/10000)*100, "%") print("Percentage of 6s:", (count6/10000)*100, "%") print("Percentage of 7s:", (count7/10000)*100, "%") print("Percentage of 8s:", (count8/10000)*100, "%") print("Percentage of 9s:", (count9/10000)*100, "%") print("Percentage of 10s:", format((count10/10000)*100, "5.2f"), "%") print("Percentage of 11s:", format((count11/10000)*100, "5.2f"), "%") print("Percentage of 12s:", format((count12/10000)*100, "5.2f"), "%") 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!