How is set() implemented?

+1 vote
How should I implement the set() method to create sets in Python?
Jul 1 in Python by Wajiha
• 1,920 points
27 views

1 answer to this question.

+1 vote

Sets in Python can be created using the set() function.

Example: 

1

2

a=set({1,'b',6.9})

print(a)

Output:  {1, ‘b’, 6.9}

You can also create an empty set using the same function.

Example:

1

2

Empty_Set=set()

print(Empty_Set)

Output: set()

answered Jul 1 by anonymous

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

Raw_input method is not working in python3. How to use it?

raw_input is not supported anymore in python3. ...READ MORE

answered May 4, 2018 in Python by aayushi
• 750 points
165 views
+1 vote
1 answer

How to check if a string is null in python

Try this: if cookie and not cookie.isspace(): # the ...READ MORE

answered Aug 20, 2018 in Python by Priyaj
• 56,940 points
4,294 views
0 votes
1 answer

How random.seed(): is used in python?

Pseudo-random number generators work by performing some ...READ MORE

answered Aug 24, 2018 in Python by Priyaj
• 56,940 points
45 views
0 votes
1 answer

How is Python 2.7.3 and Python 3.3 different?

raw_input() is not used in Python 3. Use input()  ...READ MORE

answered Sep 12, 2018 in Python by SDeb
• 13,190 points
38 views
0 votes
1 answer

What is getattr() exactly and how do I use it?

You can view a full example here: http://www.diveintopython.net/power_of_introspection/index.html Introspection ...READ MORE

answered Sep 17, 2018 in Python by bug_seeker
• 15,360 points
21 views
0 votes
1 answer

Exclusive values from two Sets in Python

There is a direct function available to ...READ MORE

answered Mar 27 in Python by Mugdha
• 600 points
49 views
0 votes
1 answer

adding elements to empty set

Adding elements to a Set: Elements can be ...READ MORE

answered Jun 13 by Nisa
• 1,090 points
29 views
+4 votes
7 answers
0 votes
1 answer

How does Python know whether a variable in the class is a method or a variable?

In python objects/variables are wrapped into methods ...READ MORE

answered Sep 18, 2018 in Python by ariaholic
• 7,340 points
57 views