Answer:
The function written in python is as follows:
import random
def simulate():
  count = 0
  for i in range(1,51):
     num = random.randint(200,1000)
     if num == 781:
       count = count + 1
  print(count)
Step-by-step explanation:
This line imports the random library
import random
This line defines the function
def simulate():
This line initializes count to 0
  count = 0
This line iterates from 1 to 50
  for i in range(1,51):
This line generates random number between 200 and 999
     num = random.randint(200,1000)
This line checks if random number is 781
     if num == 781:
If yes, the count variable is incremented by 1
       count = count + 1
This line prints the number of times 781 is generated
  print(count)