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
Write a Python program to convert temperatures to and from celsius, fahrenheit.
Rudiy27

Answer:

https://www.w3resource.com/python-exercises/python-conditional-exercise-2.php

3 0
3 years ago
What will be the value of x after the following code is executed? int x = 10; do { x *= 20; } while (x < 5); A. 10 B. 200 C.
dezoksy [38]

Answer:

Option B is the correct answer.

Explanation:

  • In the above code, the loop will execute only one time because the loop condition is false and it is the Do-While loop and the property of the Do-while loop is to execute on a single time if the loop condition is false.
  • Then the statement "x*=20;" will execute one and gives the result 200 for x variable because this statement means "x=x*20".
  • SO the 200 is the answer for the X variable which is described above and it is stated from option B. Hence it is the correct option while the other is not because--
  1. Option A states that the value is 10 but the value is 200.
  2. Option C states that this is an infinite loop but the loop is executed one time.
  3. Option D states that the loop will not be executed but the loop is executed one time
6 0
3 years ago
Read 2 more answers
What is a distinguishing feature of 5G mmWave
Tatiana [17]

Answer:

Explanation:

mmWave sử dụng phổ vô tuyến tần số cao (từ 24 GHz đến khoảng 39 GHz) để hoạt động, cho phép tăng tốc độ (và thậm chí xa hơn, trong một số trường hợp) 1Gbps. Vấn đề là việc tăng tần số lên càng cao thì khả năng đâm xuyên càng kém đi và khoảng cách truyền ngắn lại, theo Qualcomm thì đôi khi chỉ cần một bàn tay chắn trước điện thoại là đủ để máy khôngBên cạnh đó, mmWave cũng có khả năng làm hao pin thiết bị hơn, ít nhất là ở thời điểm hiện tại. Theo đó, việc tải xuống nhiều dữ liệu hơn có nghĩa là CPU điện thoại của bạn sẽ hoạt động mạnh hơn, nhanh nhất có thể để xử lý tất cả và điều đó sẽ ảnh hưởng đến tuổi thọ pin nhận tín hiệu.

5 0
3 years ago
Which of the following is NOT true about variables?
VikaD [51]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The value stored by a variable can be changed after it is assigned(true).

The value of a variable can be changed after it is assigned, for example:

int a=10;

and we can change the value of variable a in letter program such as:

a=15;

Variables are a name for a spot in the computer's memory (true).

it is true, because the variables value stored in the computer's memory and we can access theses values by their name (variable name). so Variables are a name for a spot in the computer's memory.

Variable names can be words: such as temperature or height (true).

Yes, the variable name can be words such as height, width, temperature etc.

The value stored by a variable cannot be changed after it is assigned (false).

It is noted that the value stored by a variable can be changed after it is assigned. However, it is noted that is some programming language, you can't change the value of static variable.

3 0
3 years ago
An individualized course plan for the 4 years of
spin [16.1K]

Answer:

.....

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • To type the letter address, _________ space from the dateline
    9·2 answers
  • Which are malicious codes? <br><br> JavaScript <br> Key loggers <br> Scrum <br> Spyware <br> Worms
    12·1 answer
  • Is it more beneficial to have many folders or is it better to " nest subfolders? Explain your response
    5·1 answer
  • --------------------is a host that runs software to provide information, such as web content, to other hosts.
    9·1 answer
  • How many bit does four gigabyte has
    8·2 answers
  • quiz Flavio visits a local coffee shop on his way to school and accesses its free Wi-Fi. When he first connects, a screen appear
    7·1 answer
  • 3.1.1 What type of goods are car radio and remote control.​
    12·1 answer
  • Write a sed command that will display all lines of the birthday file that do not contain the string March. What was the sed comm
    13·1 answer
  • How would you describe binary to someone ??<br> PLEASE ANSWER I WILL GIVE U BRAINLY!!
    15·2 answers
  • HELPPPP MEEEE!!!!! ITS LIFE OR MUERTEEE
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!