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.

Answers

Answer 1
Answer:

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  


Related Questions

COLLEGE

Which component of a database management system (DBMS) is responsible for data storage, manipulation, and retrieval?

Answers

Answer:

Database engine.

Explanation:

The database engine is one of the components of the database management system and its main function is to allow for storage of data, manipulation of data and retrieval of data. it is also responsible for the processing and security of data. It is sometimes called the heart of the database management system.

Other components of the database management system, among  others, are;

i. Query processors for transforming queries into low level instructions.

ii. Data manager for handling data error and recovery

iii. Data which is the main component of the database management system on which operations are done. If there were no data there would be no database management system.

HIGH SCHOOL

Why does the word stigma appear in blue? a. the word occurs only on the internet.
b. color coding is a common online method of showing emphasis.
c. clicking on the word takes you to a definition or explanation of the word.
d. the word occurs elsewhere on the page, either in the body of the text or in the web address itself.

Answers

Clicking on the word takes you to a definition or explanation of the word.
HIGH SCHOOL

A typical personal computer motherboard includes a socket for the _______.

Answers

A motherboard is the main printed circuit board (PCB).All of a computer's components connect to the motherboard. A typical personal computer motherboard includes a socket for the microprocessor, main memory, ROM, expansion slots, and many other components along with electrical pathways.


MIDDLE SCHOOL

What is a boolean data type?

Answers

Answer:

In computer science, the Boolean data type is a data type that has one of two possible values (usually denoted true and false) which is intended to represent the two truth values of logic and Boolean algebra. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is primarily associated with conditional statements, which allow different actions by changing control flow depending on whether a programmer-specified Boolean condition evaluates to true or false. It is a special case of a more general logical data type (see probabilistic logic)—logic doesn't always need to be Boolean.

Explanation:

HIGH SCHOOL

Which role is responsible for turning the product backlog into incremental pieces of functionality? bookmark this question

Answers

The answer is the team. Teams are self-establishing which no one not even the scrum master tells the team how to turn product backlog into augmentations of stoppable functionality. Each team member put on his or her knowledge to all of the complications. The interaction that outcomes progresses the entire scrum team’s general competence and usefulness. The optimal size for a scrum team is seven people, plus or minus two. When there are fewer than five team members, there is less interface and as a result less productivity improvement. The product owner and scrum master roles are not comprised in this count. Team arrangement may variation at the end of a sprint. Every time Team membership is altered, the productivity increased from self-organization is reduced.

The Development Team is responsible for turning the Product Backlog into incremental pieces of functionality.

Further Explanation:

The Product Backlog is an ordered list of all the things that have to be done in order to deliver a product. Depending on the nature of the product and the industry, this will include all kind of different work, but it is crucial to point out that it will include critical requirements, features and functions and non-critical work such as learning, experimentation, investigations into new practices and tools, etc. Scrum's Product Backlog is generally considered the most advanced agile project management backlog and teams that wish to have success with Scrum need to do  everything in their power to maintain a clear and efficient one.

Creation of Product Backlog

The Product Backlog usually starts off with only the most essential features and functionalities spelled out, possibly from a high-level road map of the product. As the team starts working on it, the Product Backlog evolves and is expanded with more details. The work that will be done in the upcoming Sprints is described in more detail than the work to be done later.

Under circumstances should the Product Backlog be re-prioritized

The Product Backlog should be re-prioritized constantly as the product evolves and new information is discovered. New business requirements, newly discovered dependencies and fluctuating market conditions are just some of the reasons for re-prioritizing the Product Backlog.

Product Owner’s Responsibility

The Product Owner is solely responsible for the Product Backlog. Only the Product Owner can add items to the backlog or remove them. They also have the final word on the ordering of the Product Backlog.  While the Product Owner is the person responsible for the Product Backlog, its refinement should be a collaborative effort where the rest of the Scrum Team contributes with its knowledge, insights and experience on the project so far.

Learn more:

  • When is implementation of a product backlog item considered complete?

        brainly.com/question/8526059

Keywords: product backlog, owner, scrum, re-prioritized, market

HIGH SCHOOL

What button should you use to view the whole presentation without exiting your present slide?

Answers

View slide show from current slide!
You hit the word exit at the top left cornner of the key pad.
HIGH SCHOOL

The _______ displays the name of the open file and the program. a. title bar
b. paragraph mark
c. address link
d. status bar

Answers

The answer is a. Title Bar

The Title Bar displays the name of the program and the name of the current open file, whether it is just displayed or being edited. It is located at the top of the program window.
MIDDLE SCHOOL

What is the best game of 2020 in pc​

Answers

Answer:we have games like alien wars call of duty astro avengers

Explanation:8

Answer:

civalazation , call of duty ,SpellBrake and Skyrim

Mark Brainliest plssssssssssss

Explanation:

HIGH SCHOOL

The intellectual property right that gives a creator control of his or her written work is known as what? A. citation
B. copyright
C. trademark
D. public domain

Answers

The intellectual property right that gives a creator control of his or her written work is known as copyright. The answer is letter B. It is important  for the author to care about copyright because he is able to; to reproduce or distribute copies, to prepare derivative works or creations based on the original work and to perform or display the work creatively.

Random Questions