Create a Python function that generates random numbers from 1 to 20 and appends them to a List.

Python –Exercises
Exercise 1 Create a Python function that generates random numbers from 1 to 20 and appends them to a List.

The function will prompt the user for the list’s length, after which it will generate random integers ranging from 1 to 20 and append them to it.

Make sure that the main program will print out the list.

To test your program.
The program input is as follows: >Enter number of elements: 3
Program expected output (hypothetical): >Randomized list is: ‘, [17, 4, 9]

Exercise 2 Create a Python program to write the following list to a file called “ex2file.text”: [“python”, “is”, “awesome”].

Every element in the list will be saved in a separate line in the TEXT file.

Create a Python function that generates random numbers from 1 to 20 and appends them to a List.
Scroll to top