1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
valina [46]
3 years ago
10

Write a Python program to do the following: (a)Use a for loop and a random integer generator to generate 5 random integers in 1

to 9. Store the random integers in a list. Display the list. (b)Use a for loop and a random integer generator to generate 5 random integers in 2 to 8. Store the random integers in a second list. Display the second list. (c)Use a for loop to compare elements in the two lists in pairs, i.e., compare the first elements in both lists, compare the second elements in the both lists, etc. Display the larger number in each comparison. The following is an example. There is no user input in this program.
Computers and Technology
1 answer:
Andrei [34K]3 years ago
6 0

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  

You might be interested in
In 1972, earlier designers built the
Sonbull [250]

The exercise is about filling in the gaps and is related to the History of the ARPANET.

<h3>What is the History of the ARPANET?</h3>

From the text:

In 1972, earlier designers built the <u>ARPANET </u>connecting major universities. They broke communication into smaller chunks, or <u>packets </u>and sent them on a first-come, first-serve basis. The limit to the number of bytes of data that can be moved is called line capacity, or <u>bandwidth</u>.

When a network is met its capacity the user experiences <u>unwanted pauses</u>. When the network is "slowing down", what is happening is users are waiting for their packet to leave the <u>queue</u>.

To make the queues smaller, developers created <u>mixed </u>packets to move <u>simultaneously</u>.

Learn more about the ARPANET at:
brainly.com/question/16433876

7 0
2 years ago
Choose the reasons why Windows Server operating systems are a popular choice for a network because they _____. Select all that a
solong [7]

Answer:

Windows Server operating systems are a popular choice for a network because they use wizards and setup devices as the user operating system, making it easier to set up network features work on networks that include using Windows operating systems as well as Mac OS, NetWare, or UNIX

Explanation:

Windows operating system is popular than any other operating system for certain reasons:

1. It provides GUI feature which any layman can access and learn easily

2. The compatibility that it provides makes it more popular

3. It supports most of the software program available in the market

4. The design of Windows is more comfortable when compared to other open source operating system.

Only thing is that it is not a free-ware. Licence needs to be purchased to use it.

6 0
3 years ago
Which of the followings is not a testingtype? [2 marks]
Agata [3.3K]

Answer:

Subsystem testing

Explanation:

This is NOT a testing type

<em>PLEASE</em><em> </em><em>DO MARK</em><em> </em><em>ME AS</em><em> </em><em>BRAINLIEST</em><em> </em><em>IF</em><em> </em><em>MY ANSWER</em><em> </em><em>IS HELPFUL</em><em> </em><em>;</em><em>)</em><em> </em>

5 0
2 years ago
If a firm is set to use open-source software with which no one in the IT department is familiar, what should it do? fire the IT
Aleonysh [2.5K]
The most efficient thing to do would be to provide training as firing or doing nothing halts productivity indefinitely while training eventually will finish
7 0
3 years ago
Read 2 more answers
Digital Sep <br> helps as reimagine outcomes true or false
iragen [17]

Answer:

true

Explanation:

mark me as brailyist pls

6 0
3 years ago
Other questions:
  • Consider the partially-filled array named a. What does the following loop do? (cin is a Scanner object)int[] a = {1, 3, 7, 0, 0,
    6·1 answer
  • Write the percentage 5 1/4 as a decimal​
    8·1 answer
  • Which option marks all modification made within a document? Review Comment Track Changes Balloons
    15·2 answers
  • Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
    6·1 answer
  • What is the traditional cognitive perspective ofHCL?
    12·1 answer
  • IOS jail broken or Android unrooted which is better to hack with
    6·1 answer
  • A business traveler notices there is an extra connector between the keyboard and the computer, in a business center. She has mos
    12·1 answer
  • An address has a house number, a street, an optional apartment number, a city, a state and a postal code. Define the constructor
    5·1 answer
  • Which of the following is NOT a type of insurance fraud?
    14·2 answers
  • Modify your main.c file so that it allocates a two dimensional array of integers so that the array has 20 rows of 30 integers in
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!