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]
2 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]2 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
What is the term used for the initial document that includes the necessary information to build a game?
arlik [135]

Game design document is the term used for the initial document that includes the necessary information to build a game

Explanation:

A game design document serves as a nexus and core to combine and list all features of a game. It consists of written descriptions, images, graphs, charts and lists of data relevant to specific parts of improvement, and is usually formed by what characteristics will be in the game, and sets out how they will all fit together.

Creating a GDD will assist the team's designer in knowing what the fragrance of the game is and the intended range of its overarching world. Holding all the game factors in one well-organized document will help the designer easily communicate their idea to the rest of the team, and also healing to pinpoint deficiencies or missing components of the game. The GDD should serve as your master checklist.

4 0
3 years ago
In Microsoft Access, what happens when you save a query once and run it but then add more to the query? What will happen? a)erro
Usimov [2.4K]
D)When the query is run again, the data that meets the new criteria will be retrieved.
5 0
3 years ago
Legal counsel has notified the information security manager of a legal matter that will require the preservation of electronic r
Ray Of Light [21]

Answer: (B) Legal hold

Explanation:

As being a security director, the security director are approached to solidify a server that run the red hat enterprise server the 5.5.

The servers are being utilized as DNS (Dynamic host service) and the server time. This is not utilized as the database, print server and the web server. There is no particular remote associations with the server.

The window of the command will be given the root accessing. Then, it provide the associated by means of a protected shell with the access root in the system.

 

3 0
3 years ago
What is a functionalist perspective of cell phones, internet and personal computers?
Sedbober [7]
<span>As these technologies are rapidly evolving a functionalist would say that they unbalance the equilibrium of the social state, and is therefore undesirable as there is more interaction and adaptation of habits from other societies. But they also say that it's not a good thing to change immediately because it might disrupt the society. Therefore it has to change slowly. </span>
3 0
3 years ago
What happens when you click on the colors button in excel?
borishaifa [10]
It writes in that color.
7 0
3 years ago
Other questions:
  • A vast global network that is made up of many smaller interconnected networks is known as:
    13·2 answers
  • When you want to avoid sending email that a recipient may feel their privacy has been invaded, how would you fill in the (To) bo
    13·1 answer
  • True or False? Most operating systems allow the user to specify a set of paths that are searched in a specific order to help res
    5·1 answer
  • Which of the following scenarios might indicate that you have been a victim of identity theft?A)Your credit report displays acco
    12·1 answer
  • What is one of the most effective security tools available for protecting users from external threats?
    15·1 answer
  • Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by ea
    12·1 answer
  • The first numerical control machine tool was demonstrated in 1952 in the United States at the Massachusetts Institute of Technol
    14·1 answer
  • What does SFA software provides tools for
    11·2 answers
  • How do I send the face to the back? Seriously, I can't find out how...
    13·1 answer
  • Which invention replaced vacuum tubes in computers?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!