Clay is playing darts. his dartboard contains ten equal-sized zones with point values from 1 to 10. write code that simulates his total score after 1000 dart tosses. make sure to use a for loop.

Respuesta :

Instead of a real language, I'll use pseudo code here: 


var TOTAL_SCORE = 0
for(var x; i<1000; i++) {
      var SCORE rand.random_integer[from 1-10];
      var TOTAL SCORE = TOTAL_SCORE + SCORE;
}

print(TOTAL_SCORE);
    

Answer:

Given parameters

Point values = 1 to 10 = 1,2,3...10

Dart tosses = 1000

Required:

Simulate total scores using a for loop

#This program is written using Python Programming Language

# Comments are used for explanatory purpose

#Program starts here

# The next line declares and initialize point_value as an array

point_value = make_array(1,2,3,4,5,6,7,8,9,10)

# The next line initializes total_score to 1

total_score =make_array(0)

# Initialise number of toss

tosses = 1000

# Simulate using for loop iteration

for i in np.arange(tosses)

result = np.random.choice(point_value)

# get score after playing each toss

total_score=np.append(total_score, result)

#calculate totalscores after 1000 games

totalscore=sum(total_score)

#Output result

print("The total score after simulation of 1000 tosses is ")

print(totalscore)

#End of program