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
Mila [183]
3 years ago
9

Write a function get_common_elems(lst1, lst2) that takes two lists of integers, lst1, and lst2, and returns a new list containin

g the elements in common between the two lists. You can assume that there are no repeated elements in the lists. Also, the ordering of the elements in the returned new list is not significant. The function signature is given below: def get_common_elems(lst1,lst2): sig : list (int),list (int) -> list(int) For example, a call to get_common_elems([5,1,4,3,6],[6,1,8,3]) will return the list 1, 3, 6. Hint: Think about how you can make use of the in operator. You only need to iterate over one of the lists.
Computers and Technology
1 answer:
zaharov [31]3 years ago
3 0

Answer:

def get_common_elems(lst1, lst2):

   common_list = []

   for e in lst1:

       if e in lst2:

           common_list.append(e)

   return common_list

Explanation:

Create a function called get_common_elems that takes two lists, lst1, and lst2

Inside the function:

Create an empty list to hold the common elements

Initialize a for loop that iterates through the lst1.

If an element in lst1 is also in the lst2, append that element to the common_list

When the loop is done, return the common_list

You might be interested in
Write an application that inputs a telephone number as a string in the form (555) 555-5555. The application should use String me
Scilla [17]

Answer:

See explaination

Explanation:

// File: TelephoneNumber.java

import java.util.Scanner;

public class TelephoneNumber

{

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

String inputNumber;

String tokens1[];

String tokens2[];

String areaCode;

String firstThree;

String lastFour;

String allSeven;

String fullNumber;

/* input a telephone number as a string in the form (555) 555-5555BsAt4ube4GblQIAAAAASUVORK5CYII= */

System.out.print("Enter a telephone number as '(XXX) XXX-XXXX': ");

inputNumber = input.nextLine();

System.out.println();

/* use String method split */

tokens1 = inputNumber.split(" ");

/* extract the area code as a token */

areaCode = tokens1[0].substring(1, 4);

/* use String method split */

tokens2 = tokens1[1].split("-");

/* extract the first three digits of the phone number as a token */

firstThree = tokens2[0];

/* extract the last four digits of the phone number as a token */

lastFour = tokens2[1];

/* concatenate the seven digits of the phone number into one string */

allSeven = firstThree + lastFour;

/* concatenate both the area code and the seven digits of the phone number into one full string separated by one space */

fullNumber = areaCode + " " + allSeven;

/* print both the area code and the phone number */

System.out.println("Area code: " + areaCode);

System.out.println("Phone number: " + allSeven);

System.out.println("Full Phone number: " + fullNumber);

}

}

8 0
3 years ago
joe is in the planning stages to make sure that an upcoming company promotion during a major sporting event will not overwhelm h
VikaD [51]

The possible solutions to recommend are that Vertical scaling, Horizontal scaling, Cloud bursting

The cloud computing business model is based on a utilitarian business model, which charges you solely for the resources you use. With this strategy, you may scale your cloud fleet to suit its present workload and add and subtract capacity as needed. Variability may be used to scale cloud services in a variety of ways, including vertical and horizontal scaling and bursting. Horizontal scaling in cloud computing refers to adding more instances rather than switching to a bigger instance size. Vertical scaling involves the addition of more or faster CPUs, memory, or I/O resources to an existing server or the replacement of one server by a more physical server.

Learn more about the utility business model here: brainly.com/question/28668154brainly.com/question/29349562

#SPJ4

3 0
2 years ago
Describe some common types of charts.​
Mekhanik [1.2K]
Bar chart.
Pie chart.
Line chart.
4 0
3 years ago
Read 2 more answers
Order the following routine maintenance tasks from most to least important when securing a computer. a. Verify anti-malware sett
spin [16.1K]

Answer:

The following are the order of the routine maintenance tasks that is C, A, B, D

Explanation:

For securing the computer system the user has to follow some steps related to the routine maintenance tasks.

  • Firstly, the user has to validate the settings on the Windows Update.
  • Then, they have to validate the settings on the anti-malware software.
  • Then, the user has to validate the setting related to the file-sharing system.
  • Finally, they have to validate the frequent optimization of hard drives or hard disks.
7 0
3 years ago
Servlet session and JSP session have differentabilities.<br>? True<br><br>? False
xxTIMURxx [149]
Your answer is true your welcome!
5 0
4 years ago
Other questions:
  • Var cookie = "username=mike2009";
    10·1 answer
  • The LTE (cellular telephone) standard supports only packet switching"". What cellular services are morst affected by this change
    15·1 answer
  • Why is it so important that you know how much traffic dfs replication requires?
    13·2 answers
  • Jason needs to design the colors for a web site that make it easy to read. Which should he consider using?
    9·1 answer
  • What type of information is kept on a database?
    10·1 answer
  • One common method of converting symbols into binary digits for computer processing is called ASCII​ (American Standard Code of I
    5·1 answer
  • A network systems administrator would most likely help with
    13·2 answers
  • A computer byte is the amount of data (measured in bits) that CPU can manipulate at one time/
    8·1 answer
  • which of the following is another term for a variable, such as cost or schedule, that limits the freedom of design, development,
    11·1 answer
  • Consider the following code snippet:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!