Answer:
//program in Python
#library
import random
#part 1
#empty list 1
list1 = []
#Generate 5 random numbers for the first list
for i in range(0, 5):
list1.append(random.randrange(1, 9+1))
#print first list
print("First List: " + str(list1))
#part b
#empty list 2
list2 = []
#Generate 5 random numbers for the second list
for i in range(0, 5):
list2.append(random.randrange(2, 8+1))
#print the second list
print("Second List: " + str(list2))
#part c
#Compare each element from both lists and print the larger one
print("Larger number in each comparison:")
for i in range(0, len(list1)):
if list1[i] >= list2[i]:
print(list1[i])
else:
print(list2[i])
Explanation:
Create an empty list.Generate 5 random number from range 1 to 9 and append them into first list.Create a second empty list.generate 5 random numbers from range 1 to 8 and append them into second list.Print both the list.Then compare both the list an print Larger in each comparison.
Output:
First List: [3, 1, 4, 9, 8]
Second List: [5, 8, 2, 7, 6]
Larger number in each comparison:
5
8
4
9
8