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
Vladimir79 [104]
3 years ago
6

The aim of this activity is to implement an algorithm that returns the union of elements in a collection. Although working with

sets is quick and easy in Python, sometimes we might want to find the union between two lists. Create a function called unite_lists, which uses a loop to go through both lists and return common elements. Do not use the built-in set function.
Computers and Technology
1 answer:
shusha [124]3 years ago
3 0

Answer:

The function in Python is as follows:

def unite_lists(A, B):

   union = []

   for elem in A:

       if elem in B:

           union.append(elem)

   return union

Explanation:

This defines the function

def unite_lists(A, B):

This initializes an empty list for the union list

   union = []

This iterates through list A

   for elem in A:

This checks if the item in list A is in list B

       if elem in B:

If it is present, the item is appended to the union list

           union.append(elem)

This returns the union of the two lists

   return union

You might be interested in
The mac group does not replace the primary functions of eocs or other dispatch organizations. True or False
Oxana [17]

Answer:

TRUE

Explanation:

MAC - multi-agency coordination is a group of executives or administrators that have the authority to control agency funds or resources while EOCs -  Emergency operation centers are in charge of carrying out of emergency tasks that requires preparedness or disasters, they ensure that work continues even in case of emergency and disasters.

7 0
3 years ago
You need to perform maintenance on a router and need to temporarily reroute traffic through another office. which would be the b
Whitepunk [10]
<span>In order to perform maintenance on a router and need to temporarily reroute traffic through another office  the best way to perform this action would be to configure a static route on the router.
</span>By doing this, the router will use the manually-<span>configured routing entry to send the packets.</span>
3 0
3 years ago
(1) prompt the user for a string that contains two strings separated by a comma. (1 pt) examples of strings that can be accepted
GalinKa [24]

package parsestrings;

import java.util.Scanner;

public class ParseStrings {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in); // Input stream for standard input

Scanner inSS = null; // Input string stream

String lineString = ""; // Holds line of text

String firstWord = ""; // First name

String secondWord = ""; // Last name

boolean inputDone = false; // Flag to indicate next iteration

// Prompt user for input

System.out.println("Enter input string: ");

// Grab data as long as "Exit" is not entered

while (!inputDone) {

// Entire line into lineString

lineString = scnr.nextLine()

// Create new input string stream

inSS = new Scanner(lineString);

// Now process the line

firstWord = inSS.next();

// Output parsed values

if (firstWord.equals("q")) {

System.out.println("Exiting.");

inputDone = true;

if (firstWord.matches("[a-zA-Z]+,[a-zA-Z]+")) {

System.out.print("Input not two comma separated words");

}

} else {

secondWord = inSS.next();

System.out.println("First word: " + firstWord);

System.out.println("Second word: " + secondWord);

System.out.println();

}

}

return;

}

}

5 0
3 years ago
What shortcut keys do i use to print something on my keyboard ?
romanna [79]
CTRL+P. It's usually pressed when you want to print something.
5 0
3 years ago
Read 2 more answers
What is the difference between - and % in mysql
jarptica [38.1K]

Answer:

Explanation:

Mysql is an open source database management system written in C and C++ language used to store, retrieve or modify a database. Mysql is used as a web database. Mysql can be combined with other programs so as to provide relational database capabilities as well as its implementation.

% matches any number of characters as well as zero characters while _ matches exactly one character.

3 0
3 years ago
Other questions:
  • Which of the following situations would not require knowledge of networking?
    6·1 answer
  • if i set my payment and use free trial on Scribd website, can i cancel my payment and NOT PAYING after one month??
    8·1 answer
  • Which type of drawer has three dispensing modes: single-dose, multi-dose, and matrix?
    13·1 answer
  • "The effectiveness of memory retrieval is directly related to the similarity of cues present when the memory was encoded to the
    11·1 answer
  • 0.005098 megaliters to liters. record your answer in whole liters
    7·1 answer
  • Edie wants to visit her university's website. What software application should she use?
    9·2 answers
  • When writing research questions, use action words, such as
    6·2 answers
  • Why is it so important to adhere to principles that have been put forth by reputable organizations to ensure that you are mainta
    10·1 answer
  • Which of the following statements is TRUE? A. A name error occurs if the variable is referenced before it is declared. B. A name
    12·1 answer
  • Write the translator of third generation language​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!