Respuesta :
Answer:
In Python:
import random
def simulate_visited_area_codes():
area_codes = []
for i in range(51):
num = random.randint(200,1000)
area_codes.append(num)
visited_codes = [289, 657, 786, 540]
count = 0
for i in range(51):
for j in range(len(visited_codes)):
if area_codes[i] == visited_codes[j]:
count+=1
return count
print("Visited Areas: "+str(simulate_visited_area_codes()))
Explanation:
So many incomplete details in your question, so I will fill in the gap (i.e. make assumptions)
The assumptions are:
- The 50 area codes is stored in area_codes list; the codes are randomly generated
- The visited area codes is stored in visited_codes list, the list is initializes with [289, 657, 786, 540]
The program and explanation is as follows: (comments are written in bold)
#This imports the random module
import random
#This defines the function
def simulate_visited_area_codes():
#Thie initializes area_codes to an empty list
area_codes = []
#This iterates from 1 to 50 and generate 50 random numbers to the area_codes list
for i in range(51):
num = random.randint(200,1000)
area_codes.append(num)
#This initializes the visited_code
visited_codes = [289, 657, 786, 540]
#This initializes count variable to 0
count = 0
#This iterates through the list and looks for matching code between the area_code and the visited_code lists
for i in range(51):
for j in range(len(visited_codes)):
if area_codes[i] == visited_codes[j]:
#The count variable is incremented by 1 for matching codes
count+=1
#This returns the count
return count
#The main begins here and prints the number of area code visited
print("Visited Areas: "+str(simulate_visited_area_codes()))
Simulate Function:
Simulate one or more responses from the distribution corresponding to a fitted model object.
The code is shown below:-
visited_test_statistics_under_null = make_array()
repetitions = 20000
for i in np.arange(repetitions):
new_sum_of_correct_area_code = simulate_visited_area_codes()
visited_test_statistics_under_null = np.append(visited_test_statistics_under_null, new_sum_of_correct_area_code)
visited_test_statistics_under_null( )
Learn more about the topic Simulate Function:
https://brainly.com/question/14492046