Menu

Trying Write Program Python Main Function Void Function Named Numbers Takes Arguments Retu Q43779443

I am trying to write a program in python that has a main()function and a void function named numbers() that takes noarguments and returns the variable used for the total. The numbersfunction generates 20 random integers, it is required to use therandom.randint method to generate these numbers. The range would be8 to 59 inclusive, (duplicates are okay), and prints them all onone line separated by spaces. A loop is required for this, and theloop should also total up the integers so the sum can be displayedwhen the loop ends. The main() function calls the numbers()function.
Here is what I have so far, but it only displays 1 number and notthe 20 that should be displayed. I need some guidance on what I’mdoing wrong. Thank you!

import random

def numbers():
#function that generates 20 random integers
#prints on single line and prints the total sum
#set sum to 0
total=0

for number in range(20):
number = random.randint(8, 59)
print (number, end=”)

  #add all numbers for sum
  total+=number
  print (‘n The total is ‘,total)

def main():
  #call the function
  numbers()

main()

Expert Answer


Answer to I am trying to write a program in python that has a main() function and a void function named numbers() that takes no ar…

OR