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
sergejj [24]
2 years ago
6

Write a Python function check_subset() that takes in two Python lists, representing sets of integers, A and B. Your function sho

uld return a single Boolean (True or False) for whether or not either set is a subset of the other. A and B are sets, and not necessarily non-empty.
Computers and Technology
1 answer:
wlad13 [49]2 years ago
6 0

Answer:

  1. def check_subset(l1, l2):
  2.    status = False
  3.    count = 0
  4.    if(len(l1) > len(l2)):
  5.        for x in l2:
  6.            for y in l1:
  7.                if x == y:
  8.                    count += 1
  9.        if(count == len(l2)):
  10.            return True  
  11.        else:
  12.            return False
  13.    else:
  14.        for x in l1:
  15.            for y in l2:
  16.                if x==y:
  17.                    count += 1
  18.        if(count == len(l1)):
  19.            return True  
  20.        else:
  21.            return False
  22. print(check_subset([1,4,6], [1,2,3,4,5,6]))
  23. print(check_subset([2,5,7,9,8], [7,8]))
  24. print(check_subset([1, 5, 7], [1,4,6,78,12]))

Explanation:

The key idea of this solution is to create a count variable to track the number of the elements in a shorter list whose value can be found in another longer list.

Firstly, we need to check which list is shorter (Line 4). If the list 2 is shorter, we need to traverse through the list 2 in an outer loop (Line 5) and then create another inner loop to traverse through the longer list 1 (Line 6).  If the current x value from list 2 is matched any value in list 1, increment the count variable by 1. After finishing the outer loop and inner loop, we shall be able to get the total count of elements in list 2 which can also be found in list 1. If the count is equal to the length of list 2, it means all elements in the list 2 are found in the list 1 and therefore it is a subset of list 1 and return true (Line 10-11) otherwise return false.

The similar process is applied to the situation where the list 1 is shorter than list 2 (Line 15-24)

If we test our function using three pairs of input lists (Line 26-28), we shall get the output as follows:

True

True

False

You might be interested in
Write a police description a person who know you well​
SIZIF [17.4K]

Answer:

I will be describing Jude. He is a neighbor.

Explanation:

A police description refers to the method of describing a person using high-level detailing. An example is given below:

  1. He is a Five feet-three male caucasian
  2. With brown eyes and
  3. an Australian accent
  4. He has a military haircut
  5. About 38 years
  6. Weighs about 95Kg
  7. and dresses casually
  8. he walks with a slant to the left
  9. a dove tattoed at the back of his neck
  10. and a birthmark on his left ear lobe

Cheers

3 0
2 years ago
What number will this code return?<br> Math.max(7, 5, 9);
Anon25 [30]
9

JavaScript’s Math module has a max method that finds the max of the given arguments.

I’m not sure how I can be any clearer
I’ve attached a screenshot if you still have no clue

8 0
1 year ago
An administrator has initiated the process of deploying changes from a sandbox to the production environment using the Force IDE
Pani-rosa [81]

Option A because the environment should be selected for which the changes are to be applied. In a time Force IDE has many project environments for example maybe a java project and C++ project would be there on sandbox, so the environment selection is important.

Option B because the related changed sets should be specified so that other developers that have access to the project can see the changes being made.

Option D The data fields that are needed to be deployed should also be provided so that the updated version can be seen by other developers.

Rejected Options :

Option C user name and password has nothing to do with the production environment because if the user has it only then it can come and make changes.

6 0
2 years ago
Type the correct answer in the box. Spell all words correctly. What type of network is the Internet? The Internet is an example
denis23 [38]

Answer:

The answer is WAN (Wide Area Network).

Explanation:

  • The Internet is an example of WAN. It stands for wide area network. It is an information network that commonly links to computers that cover a broad specific area. In a WAN, two towns, states, or countries are linked.  
  • The main purpose of using WAN includes a wide range, offers unified information, get upgraded files and software, several email sharing applications, etc.
6 0
3 years ago
For the best night photographs, you’ll need to have a camera with a shutter speed of about 3 to 30 seconds
Alex_Xolod [135]
What are you trying to ask?

8 0
3 years ago
Other questions:
  • Identify the correct XHTML syntax for inserting an image as a hyperlink from the options provided. A. book.gif B. C. D.
    9·1 answer
  • How much does a Canon PowerShot G7X cost in America?
    14·1 answer
  • What is the main purpose of cutting plane line arrows?
    7·1 answer
  • Prove each statement using a proof by exhaustion. For every integer n such that 0 lessthanorequalto n &lt; 3, (n + 1)^2 &gt; n^3
    9·1 answer
  • Before the electronic era information was usually directly communicated and not recorded, much of the information you received w
    9·1 answer
  • PLEASE HELP QUICK WILL GIVE BRAINLY
    6·1 answer
  • Haley is helping to choose members for a customer satisfaction team. Which
    6·1 answer
  • This project involves writing a program that encodes and decodes messages. The program should prompt the user to select whether
    15·1 answer
  • 14. Which of the following information about the ESRT T-teen rating rating is FALSE?
    15·1 answer
  • What do you mean by Graphics editing​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!