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
sesenic [268]
3 years ago
7

Write a function list_intersection that takes two lists as parameters. Return a list that gives the intersection of the two list

s- ie, a list of elements that are common to both lists. Run the following test cases and make sure your results are the same (the ordering of your outputs does not matter - [3,2] is the same as [2,3]):
Computers and Technology
2 answers:
Contact [7]3 years ago
6 0

Answer:

  1. def list_intersection(l1, l2):
  2.    inter_list = []
  3.    for x in l1:
  4.        for y in l2:
  5.            if(y == x):
  6.                if(x not in inter_list):
  7.                    inter_list.append(x)
  8.    return inter_list  
  9. list1 = [3, 5, 5, 7, 7, 10]
  10. list2 = [4, 6, 7, 7, 8, 8, 10]
  11. print(list_intersection(list1, list2))

Explanation:

The solution code is written in Python.

Firstly, create a function list_intersection that takes two input lists, l1 and l2 (Line 1). Next, create a new list, inter_list, to hold the intersect numbers from the two input lists (Line 2).

Create a two-layer for loop to traverse through every number in l1 and compare it with every number in l2 (Line 4 - 5). If any one of the numbers from l2 is equal to the current number from L1, add this common number to inter_list (Line 8). This is important to check the current common number is not in the inter_list (Line 7) to avoid number duplication.

We can test the function using the two sample lists (Line 12 -13) and print the result (Line 14). We shall get the output [7, 10].

Nataliya [291]3 years ago
4 0

Answer:

def list_intersection(list1, list2):

   intersected_list = [number for number in list1 if number in list2]

   return intersected_list

 

list1 = [11, 5, 676, 0, 42, 32]

list2 = [0, 89, 211, 11]

print(list_intersection(list1, list2))

Explanation:

- Inside the function, create a new list called <em>intersected_list </em>to check if any number in <em>list1</em> is also in the <em>list2</em>. If a match is found put the number in the <em>intersected_list. </em>* Take a look how Python enables us to do this with just one line of code

- Then create two lists to compare

- Call the function and print the result

You might be interested in
What is the main reason that IT managers believe the future IT career model will be diamond-shaped, with few entry-level IT jobs
Valentin [98]
<span>In which career field, would the Computing Technology Industry Association's CompTIA A+ certification be useful?</span>
4 0
3 years ago
Rows within a spreadsheet are identified by:
EleoNora [17]

Answer:

Option C: Numbers.

Explanation:

By default, rows within a spreadsheet are identified by Numbers i.e. 1,2,3,............

Total rows are 1048575 in one spreadsheet.

7 0
4 years ago
Which type of ICS facility is used to temporarily position and account for personnel, supplies, and equipment awaiting assignmen
Black_prince [1.1K]

Answer:

C. Staging Area

Explanation:

According to my research on different ICS facilities, I can say that based on the information provided within the question the facility being described here is called a Staging Area. Like mentioned in the question a staging area is a location set up at an incident where resources and personnel can be placed while waiting on instructions to proceed with an operation or assignment.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

6 0
3 years ago
Anyone wanna hop on 1v1.lol<br> party code : usfhb6
hjlf

Answer:

thx for the points

Explanation:

8 0
3 years ago
Read 2 more answers
The performance of a client-server system is strongly influenced by two major network characteristics: the bandwidth of the netw
Rama09 [41]

Answer:

A bandwidth is the maximum rate of transfer of data across a given path

Latency refers to the delay of data to travel or move between a source and destination

An example of a high bandwidth and high latency network is the Satellite Internet connectivity.

An example of a low bandwidth and latency network is the telephone system connection.

Explanation:

Solution

Bandwidth: Bandwidth determines how fast data can be transferred for example, how many bits/sec it can transport.

Latency: It refers to the delay or how long it takes for data to travel between it's source and destination.

An example of a high bandwidth and high latency network is the Satellite internet connection.

Satellite internet connection: This is responsible for the connectivity of several systems, it has a high bandwidth, since satellite are in space, due to distance it has a high latency.

So, satellite internet connection is compensated with high latency and high bandwidth.

An example of a low bandwidth and low latency network is the Telephony network.

Telephone/telephony internet connection: This connection does not have much data for transfer. it has low size audio files of which a low bandwidth range. also for both end or end users to understand and talk to each other, it has low latency.

3 0
3 years ago
Other questions:
  • The program prompts the user to interactively enter eight batting averages, which the program stores in an array. The program sh
    9·1 answer
  • Software license infringement is also often called software __________.
    11·2 answers
  • Rachel uses a word processor to write short stories. However, most of her time is spent toying with the keys, rather than in wri
    13·2 answers
  • When looking to ensure your website is easily accessible by mobile users, what should you focus on doing first
    8·1 answer
  • How are engineers are related to technology
    13·1 answer
  • List 3 items that were on kens resume that should have been excluded
    13·2 answers
  • Careers in information technology deal with
    12·2 answers
  • The term "exception propagation" means:
    5·1 answer
  • Multiple Choice
    9·1 answer
  • Assume that you have the business data in various sources such as Excel, .csv, text files and Access, Oracle databases. Write th
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!