How is set() implemented?

+1 vote
How should I implement the set() method to create sets in Python?
Jul 1, 2019 in Python by Wajiha
• 1,950 points
55 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, 2019 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
969 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
• 57,550 points
13,308 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
• 57,550 points
80 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,250 points
102 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,400 points
72 views
0 votes
1 answer

Exclusive values from two Sets in Python

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

answered Mar 27, 2019 in Python by Mugdha
• 600 points
99 views
0 votes
1 answer

adding elements to empty set

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

answered Jun 13, 2019 by Nisa
• 1,090 points
68 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 aryya
• 7,370 points
102 views