58.6k views
2 votes
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.

User IDou
by
5.9k points

2 Answers

7 votes

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()

Step-by-step 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.

User Mson
by
6.4k points
3 votes

Answer:

The Code is attached

Step-by-step 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
Python code Create a function called FillNumbers that will fill a list of 10 random-example-1
User David Cordero
by
5.8k points