Python code


Create a function called FillNumbers that will fill a list of 10 random integers between 1 and 10. Write the function so that it returns this list back to main(). Don't forget to include the library that allows you to create random numbers. You can list your import statement outside of the function.

Respuesta :

Answer:

The Code is attached

Explanation:

  1. First import the library "random"
  2. Then create a empty list "number_list"
  3. in a loop 10 times
  4. choose a random number between 1 and 10
  5. append the number into the number_list
  6. return number_list
Ver imagen dogacandu

import random

def FillNumbers(int ):

   print(""Printing random numbers between 1 to 10"")

   print(random.randrange(1,10))

def Main():

       for K in range(1,10):

           FillNumbers(K)

Main()

Explanation:

We import random library so that we use or call random numbers  with specific range.

In FILLNumbers function we just print random number by call random.randage(1,10). Random.randage is inbuilt functions which is available in random library.

Since in python any function can be defined as main function not like other software like c, c++. To acheive we use def  as main() to call the FILLNumbers(k). FILLNumbers(K) been called 10 times for that for loop been used with range(1,10)

At last Main() been called for execute first function to get the output.