Answer:
- def check_subset(l1, l2):
- status = False
- count = 0
- if(len(l1) > len(l2)):
- for x in l2:
- for y in l1:
- if x == y:
- count += 1
-
- if(count == len(l2)):
- return True
- else:
- return False
-
- else:
- for x in l1:
- for y in l2:
- if x==y:
- count += 1
-
- if(count == len(l1)):
- return True
- else:
- return False
-
- print(check_subset([1,4,6], [1,2,3,4,5,6]))
- print(check_subset([2,5,7,9,8], [7,8]))
- 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
Answer:
Name.
Explanation:
The constructor in the class must have the same name as the class.Constructors are used to initialize the object when created.There are basically three types of constructors which are as following:-
- Default Constructor.
- Parameterized Constructor.
- Copy Constructor.
Default Constructor:-This constructor is already present in the class when the class is defined.It does not have any arguments.
Parameterized Constructor:-As the name suggests this constructor have parameters that are used to initialize the object.
Copy Constructor:-This constructor is called whenever an object is copying the values of other object.For example:-
There is already an object present with name obj1.
class obj2=obj1;
google or search through pvps
Answer:
SCSI.
Explanation:
It is a set of ANSI-developed simultaneous interface requirements for connecting scanners, drives, printers, and many other devices to systems.
Although when Tim has such an outdated network system which is used as a backup by his corporation. Then hard drive may have gone wrong and required replacement. The connector used by the hard disk drive is not something he has ever seen before, but he upload photos of that on the community board of the organization to aid determine what kind of hard disk drive they will also have to order.
So, according to the following scenario he required SCSI cable.
Answer:CPU stands for the central processing unit. CPU is not a peripheral device.
Explanation:
CPU stands for the central processing unit. CPU is not a peripheral device.