Sets are unordered collections of unique elements. Elements within a set cannot be accessed by index since sets are unordered. Common set operations include union, intersection, difference, and symmetric difference. Sets can be created using curly brackets or the set() function. Items can be added and removed from sets using methods like add(), remove(), discard(), and clear(). The length of a set can be determined using len(). Mathematical set relationships like subset, superset, and disjointness can be tested using methods like issubset(), issuperset(), and isdisjoint().
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
This is presentation, that covers all the important topics related to strings in python. It covers storing, slicing, format, concatenation, modification, escape characters and string methods.
The file attatched also includes examples related to the slides shown.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
Arrays In Python | Python Array Operations | EdurekaEdureka!
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Arrays in Python' will help you establish a strong hold on all the fundamentals in the Python programming language. Below are the topics covered in this PPT:
What is an array?
Is python list same as an array?
How to create arrays in python?
Accessing array elements
Basic array operations
- Finding the length of an array
- Adding Elements
- Removing elements
- Array concatenation
- Slicing
- Looping
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Question In C Programming In mathematics, a set is a colle...Sav.pdfarihantcomp1008
Question: In C Programming: In mathematics, a set is a colle...
Save
In C Programming:
In mathematics, a set is a collection of distinct elements (say integer numbers). For example,
A={2, 5, 7} and B={3, 5, 8, 10} are two different sets. There are several basic operations for
constructing new sets from given two sets, but let\'s just consider three basic ones:
C = union(A,B); ---> C = A B={2, 5, 7, 8, 10} C = intersection(A,B); ---> C = A B={5}
C = difference(A,B); ---> C = A-B = A \\ B ={2, 7} also aka. complement
You are asked to develop a set library (using two different representations: array and link list)
and then implement a driver program that gets two sets and one of the above operation as a
command to apply, then it prints the resulting set...
Developing set library: For interface, create an interface file set.h which contains boiler plate and
the followings:
typedef int setElementT;
typedef struct setCDT *setADT;
setADT setNew(); /* create a new empty set */
void setFree(setADT S); /* free the space allocated for the set S */
int setInsertElementSorted(setADT S, setElementT E);
/* if not successful, return 0; otherwise, return the num of elements after the insertion. Also note
that the elements might be given in different orders, but your function should always keep the set
in a sorted manner after each insertion */
setADT setUnion(setADT A, setADT B);
/* returns a new set containing A B */
setADT setIntersection(setADT A, setADT B);
/* returns a new set containing A B */
setADT setDifference(setADT A, setADT B);
/* returns a new set containing A \\ B */
int setCardinality(setADT S);
/* return the number of elements in S */
void setPrint(setADT S, char *name);
/* print elements of S, A = {2, 5, 7} */
For implementation, you will be asked to have two different implementations:
(40pt) First implement set library as setArrayImp.c which uses a constant size array to store set
elements (suppose max set size is 100). [hint: see ch2 slides 72-78 ]
(40pt) Second implement this library as setLinkedListImp.c which uses a dynamic single linked
list to store set elements.
Develop a driver.c program and compile it with two different imp of set library (20 pt)
1. Create two sets called A and B.
2. Ask user to enter positive integers for set A (end input when user enters -1)
3. Ask user to enter positive integers for set B (end input when user enters -1)
4. In a loop 4.1. Ask user to enter a command:
4.2 If Q is entered, quit from this loop.
4.3 If U, I, or D is entered, compute set C as union, intersection, or difference. setPrint(A, \"A\");
setPrint(A, \"B\"); setPrint(C, \"C\"); print the number of elements in C setFree(C);
5. free A and B
Compile/execute driver.c with setArrayImp.c as well as setListImp.c
//no include files needed
Solution
Create set.h first with the following
typedef int setElementT;
typedef struct setCDT *setADT;
setADT setNew(); /* Creates a new empty set */
void setFree(setADT S); /* Frees the space allocated for the set .
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
This is presentation, that covers all the important topics related to strings in python. It covers storing, slicing, format, concatenation, modification, escape characters and string methods.
The file attatched also includes examples related to the slides shown.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
Arrays In Python | Python Array Operations | EdurekaEdureka!
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Arrays in Python' will help you establish a strong hold on all the fundamentals in the Python programming language. Below are the topics covered in this PPT:
What is an array?
Is python list same as an array?
How to create arrays in python?
Accessing array elements
Basic array operations
- Finding the length of an array
- Adding Elements
- Removing elements
- Array concatenation
- Slicing
- Looping
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Question In C Programming In mathematics, a set is a colle...Sav.pdfarihantcomp1008
Question: In C Programming: In mathematics, a set is a colle...
Save
In C Programming:
In mathematics, a set is a collection of distinct elements (say integer numbers). For example,
A={2, 5, 7} and B={3, 5, 8, 10} are two different sets. There are several basic operations for
constructing new sets from given two sets, but let\'s just consider three basic ones:
C = union(A,B); ---> C = A B={2, 5, 7, 8, 10} C = intersection(A,B); ---> C = A B={5}
C = difference(A,B); ---> C = A-B = A \\ B ={2, 7} also aka. complement
You are asked to develop a set library (using two different representations: array and link list)
and then implement a driver program that gets two sets and one of the above operation as a
command to apply, then it prints the resulting set...
Developing set library: For interface, create an interface file set.h which contains boiler plate and
the followings:
typedef int setElementT;
typedef struct setCDT *setADT;
setADT setNew(); /* create a new empty set */
void setFree(setADT S); /* free the space allocated for the set S */
int setInsertElementSorted(setADT S, setElementT E);
/* if not successful, return 0; otherwise, return the num of elements after the insertion. Also note
that the elements might be given in different orders, but your function should always keep the set
in a sorted manner after each insertion */
setADT setUnion(setADT A, setADT B);
/* returns a new set containing A B */
setADT setIntersection(setADT A, setADT B);
/* returns a new set containing A B */
setADT setDifference(setADT A, setADT B);
/* returns a new set containing A \\ B */
int setCardinality(setADT S);
/* return the number of elements in S */
void setPrint(setADT S, char *name);
/* print elements of S, A = {2, 5, 7} */
For implementation, you will be asked to have two different implementations:
(40pt) First implement set library as setArrayImp.c which uses a constant size array to store set
elements (suppose max set size is 100). [hint: see ch2 slides 72-78 ]
(40pt) Second implement this library as setLinkedListImp.c which uses a dynamic single linked
list to store set elements.
Develop a driver.c program and compile it with two different imp of set library (20 pt)
1. Create two sets called A and B.
2. Ask user to enter positive integers for set A (end input when user enters -1)
3. Ask user to enter positive integers for set B (end input when user enters -1)
4. In a loop 4.1. Ask user to enter a command:
4.2 If Q is entered, quit from this loop.
4.3 If U, I, or D is entered, compute set C as union, intersection, or difference. setPrint(A, \"A\");
setPrint(A, \"B\"); setPrint(C, \"C\"); print the number of elements in C setFree(C);
5. free A and B
Compile/execute driver.c with setArrayImp.c as well as setListImp.c
//no include files needed
Solution
Create set.h first with the following
typedef int setElementT;
typedef struct setCDT *setADT;
setADT setNew(); /* Creates a new empty set */
void setFree(setADT S); /* Frees the space allocated for the set .
Set relationship, set operation and sigmoidKanza batool
It is defined as the relation between two sets.
Terminology used to describe sets Relationship
Membership (∈)
Subsets (⊆)/ Supersets (⊇)
Disjoint Sets
NULL Set ( ∅ )
Family Sets
Power Sets ( P(set Name) )
Explains what is a Set and Dictionary. Explains various operations on Set, Set class methods for manipulation and frozensets. Explains various Dictionary class methods and their usage, use of iterators in Dictionary and use of for loop in dictionary
package lab7 public class SetOperations public static.pdfsyedabdul78662
package lab7;
public class SetOperations {
public static int[] makeSet(int[] data) {
if (data == null) {
return null;
}
int[] result = new int[data.length];
int index = 0;
boolean found;
for (int i = 0; i < data.length; i++) {
found = false;
for (int j = 0; j < index; j++) {
if (data[i] == result[j]) {
found = true;
break;
}
}
if (!found) {
result[index++] = data[i];
}
}
int[] finalResult = new int[index];
System.arraycopy(result, 0, finalResult, 0, index);
return finalResult;
}
public static boolean isSet(int[] data) {
if (data == null) {
return false;
}
for (int i = 0; i < data.length; i++) {
for (int j = i + 1; j < data.length; j++) {
if (data[i] == data[j]) {
return false;
}
}
}
return true;
}
public static int[] union(int[] setA, int[] setB) {
if (!isSet(setA) || !isSet(setB)) {
throw new IllegalArgumentException("One of the input arrays is not a set");
}
int[] result = new int[setA.length + setB.length];
int index = 0;
for (int i = 0; i < setA.length; i++) {
result[index++] = setA[i];
}
boolean found;
for (int i = 0; i < setB.length; i++) {
found = false;
for (int j = 0; j < setA.length; j++) {
if (setB[i] == setA[j]) {
found = true;
break;
}
}
if (!found) {
result[index++] = setB[i];
}
}
int[] finalResult = new int[index];
System.arraycopy(result, 0, finalResult, 0, index);
return finalResult;
}
public static int[] intersection(int[] setA, int[] setB) {
if (!isSet(setA) || !isSet(setB)) {
throw new IllegalArgumentException("One of the input arrays is not a set");
}
int[] smallerSet, largerSet;
if (setA.length < setB.length) {
smallerSet = setA;
largerSet = setB;
} else {
smallerSet = setB;
largerSet = setA;
}
int[] result = new int[smallerSet.length];
int index = 0;
for (int i = 0; i < smallerSet.length; i++) {
for (int j = 0; j < largerSet.length; j++) {
if (smallerSet[i] == largerSet[j]) {
result[index++] = smallerSet[i];
break;
}
}
}
int[] finalResult = new int[index];
System.arraycopy(result, 0, finalResult, 0, index);
return finalResult;
}
public static int[] difference(int[] setA, int[] setB) {
if (!isSet(setA) || !isSet(setB)) {
throw new IllegalArgumentException("One of the input arrays is not a set");
}
int[] diff = new int[setA.length];
int index = 0;
for (int i = 0; i < setA.length; i++) {
boolean found = false;
for (int j = 0; j < setB.length; j++) {
if (setA[i] == setB[j]) {
found = true;
break;
}
}
if (!found) {
diff[index++] = setA[i];
}
}
int[] result = new int[index];
System.arraycopy(diff, 0, result, 0, index);
return result;
}
}
Lab 7: Set Operations with Arrays Grading and Submission You are to write a complete Java
program that meets the requirements outlined in the Lab 7 Tasks section. Push your code to
GitHub in the same way you've pushed previous Labs: - Your code should be in a class named
"SetOperations.java" and in a package named "lab7" - So, the path to your code should be:
"Labs/Lab07/src/lab7/SetOperations.java" There will be 6 points for this lab, broken down in the
following way: 1. makeSet is implement.
Other than some generic containers like list, Python in its definition can also handle containers with specified data types. Array can be handled in python by module named “array“. They can be useful when we have to manipulate only a specific data type values.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
2. SET
• A set is an unordered collection of items. Every element is unique (no
duplicates) and must be immutable (which cannot be changed).
• However, the set itself is mutable. We can add or remove items from it.
• Sets can be used to perform mathematical set operations like union,
intersection, symmetric difference etc.
3. Creating SET
• A set is a collection which is unordered and unindexed.
• A set iss created by placing all the items(elements) inside with curly
brackets{},separated by comma or by using the built-in function set().
• It can have any number of items and they may be of different types (integer, float, tuple,
string etc.).
• Empty curly braces {} will make an empty dictionary in Python.
• To make a set without any elements we use the set() function without any argument.
4. Creating SET
• Important : But a set cannot have a mutable element, like list, set or dictionary, as its
element.
Example :
set_four={1,2,[3,4]}
print set_four
#output : set_four={1,2,[3,4]}
TypeError: unhashable type: 'list’Because Set is immutable
and list is mutable so we can’t contain list in set.
5. Creating SET
• We can make set from a list.
my_set = set([1,2,3,2])
print(my_set)
#Output :
{1, 2, 3}
6. Access Items
• You cannot access items in a set by referring to an index, since sets are unordered the
items has no index.
• But you can loop through the set items using a for loop, or ask if a specified value is
present in a set, by using the in keyword.
thisset = {“sad", “happy", “love“,”hate”}
for x in thisset:
print(x)
# Output :
sad
happy
love
hate
7. Change SET methods
• To add one item to a set use the add( ) method.
• To add more than one item to a set use the update() method.
• The update() method can take tuples, lists, strings or other sets as its
argument. In all cases, duplicates are avoided.
8. Remove element from SET
• A particular item can be removed from set using methods, discard() and remove().
• The only difference between the two is that, while using discard() if the item does not
exist in the set, it remains unchanged. But remove() will raise an error in such condition.
• You can also use the pop(), method to remove an item, but this method will remove the
last item. Remember that sets are unordered, so you will not know what item that gets
removed. The return value of the pop() method is the removed item.
• The clear() method empties the set.
• The del keyword will delete the set completely.
10. Union( )
• Union operation is performed using | operator. Same can be accomplished using the
method union(). Union of sets is a set of all elements from both A & B sets.
# set operations
A = {1, 3, 5, 7, 9}
B = {2, 4, 6,8,10}
print(A|B)
print(A.union(B))
print(B.union(A))
#Above all print statement output will be same.
#Output :{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
11. Intersection( )
• Intersection operation is performed using & operator. Same can be accomplished using
the method intersection(). Intersection of sets is a set of elements that are common in
both sets.
# set operations
A = {1, 3, 4, 7, 8}
B = {2, 4, 3,8,10}
print(A&B)
print(A.intersection(B))
print(B.intersection(A))
#Above all print statement output will be same.
#Output :{3,4,8}
12. Difference( )
• Difference is performed using - operator. Same can be accomplished using the method
difference(). Difference of A and B (A - B) is a set of elements that are only in A but not
in B. Similarly, B - A is a set of element in B but not in A.
# set operations
A = {1, 3, 4, 7, 8}
B = {2, 4, 3,8,10}
print(A-B)
print(A. difference(B))
#output :{1, 7}
print(B-A)
print(B.difference(A))
#output :{2,10}
13. symmetric_difference( )
• Symmetric Difference of A and B is a set of elements in both A and B except those that
are common in both. Symmetric difference is performed using ^ operator. Same can be
accomplished using the method symmetric_difference().
# set operations
A = {1, 3, 4, 7, 8}
B = {2, 4, 3,8,10}
print(A^B)
print(A. symmetric_difference(B))
print(B^A)
print(B. symmetric_difference (A))
#Above all print statement output will be same.
#output :{1,2,7,10}
14. Copy( )
• The copy() method copies the set.
fruits = {"apple", "banana", "cherry"}
x = fruits.copy()
print(x)
15. difference_update( )
• The difference_update() method removes the items that exist in both sets.
• The difference_update() method is different from the difference() method, because the
difference() method returns a new set, without the unwanted items, and the
difference_update() method removes the unwanted items from the original set.
• Syntax :
• A.difference_update(B)
• Here, A and B are two sets. The difference_update() updates set A with the set
difference of A-B.
• The difference_update() returns None indicating the object (set) is mutated.
16. difference_update( )
• Example:
A = {'a', 'c', 'g', 'd'}
B = {'c', 'f', 'g'}
result = A.difference_update(B)
print('A = ', A)
print('B = ', B)
print('result = ', result)
#output: ( 'A = ', set(['a', 'd']))
('B = ', set(['c', 'g', 'f']))
('result = ', None)
A = {'a', 'c', 'g', 'd'}
B = {'c', 'f', 'g'}
result = B.difference_update(A)
print('A = ', A)
print('B = ', B)
print('result = ', result)
#output: ('A = ', set(['a', 'c', 'd', 'g']))
('B = ', set(['f']))
('result = ', None)
17. symmentric_difference_update( )
• The symmetric_difference_update() method finds the symmetric
difference of two sets and updates the set calling it.
• Syntax :
• A.symmetric_difference_update(B)
• The symmetric_difference_update() returns None (returns nothing).
Rather, it updates the set calling it.
18. symmentric_difference_update( )
Example:
A = {'a', 'c', 'd'}
B = {'c', 'd', 'e’ }
result=A.symmetric_difference_update(B)
print('A =', A)
print('B =', B)
print('result =', result)
Output :
A = {'a', 'e'}
B = {'d', 'c', 'e'}
result = None
19. intersection_update( )
• The intersection of two or more sets is the set of elements which are
common to all sets.
• Syntax:
• A.intersection_update(*other_sets)
• The intersection_update() allows arbitrary number of arguments (sets).
• This method returns None (meaning, absence of a return value). It only
updates the set calling the intersection_update() method.
This method returns None (meaning, absence of a return value). It only updates the set calling the intersection_update() method.
20. intersection_update( )
Example :
A = {1, 2, 3, 4}
B = {2, 3, 4, 5, 6}
C = {4, 5, 6, 9, 10}
result = C.intersection_update(B, A)
print('result =', result)
print('C =', C)
print('B =', B)
print('A =', A)
#Output :
result = None
C = {4}
B = {2, 3, 4, 5, 6}
A = {1, 2, 3, 4}
21. issubset( )
• The issubset( ) method returns True if all elements of a set are present in another
set (passed as an argument). If not, it returns False.
• Set A is said to be the subset of set B if all elements of A are in B.
• Syntax:
• A.issubset(B)
• The issubset() returns
✓True if A is a subset of B
✓False if A is not a subset of B
22. issuperset( )
• The issuperset() method returns True if all items in the specified set exists in the original set,
otherwise it retuns False.
• Syntax:
• A.issuperset(B)
• The issuperset() returns
✓ True if A is a superset of B
# Return True if all items in set B are present in set A.
✓ False if A is not a superset of B
# Return False if not all items in set B are present in set A.
23. issubset( )
• Example :
A = {1, 2, 3}
B = {1, 2, 3, 4, 5}
C = {1, 2, 4, 5}
print(A.issubset(B))
print(B.issubset(A))
print(A.issubset(C))
print(C.issubset(B))
Output:
True
False
False
True
24. disjoint( )
• The isdisjoint() method returns True if two sets are disjoint sets. If not, it returns False.
• Two sets are said to be disjoint sets if they have no common elements.
• Syntax:
• A.disjoint( )
• The isdisjoint() method returns
✓ True if two sets are disjoint sets
✓ (if set_a and set_b are disjoint sets in above syntax)
✓ False if two sets are not disjoint sets
25. len( ),set( )
• To determine how many items a set has, use the len() method.
• Syntax: len(set_name)
• It is also possible to use the set() constructor to make a set.
• Example:
thisset = set(("apple", "banana", "cherry"))
# note the double round-brackets
print(thisset)