Home >> Python Tutorial >> Python Set
Edit Template
Edit Template

Python Set in Hindi

What is Python Set in Hindi

Set, elements का  unordered ओर unindexed collections होता है इसके elements unique होते हैं मतलब कोई भी elements repeat नहीं हो सकता और set unordered होता है इसलिए set के elements को हम directly indexing से access नहीं कर सकते, set को { }  के define किया जाते हैं या फिर हम set banane के लिए set function का भी use कर सकते हैं।

🐍
tuple.py
Copy to clipboard
my_set = {5, 7, 3, 1}
print(my_set)

# using set() method
a = [4, 2, 7]
my_set = set(a)
print(my_set)

# create empty set
empty_set = set()

How to Iterate Set Items in Hindi

loop का use करके हम set के elements को iterate कर सकते है, ध्यान दीजिए हम indexing से set के items को access नहीं कर सकते है। 

🐍
access.py
Copy to clipboard
fruits = {"banana", "apple", "guava"}
for i in fruits:
    print(i)

# Output :  banana
#           apple
#           guava

Set Methods in Hindi

python मे set के लिए build-in methods होते है, जिनका use करके set के साथ अलग अलग operation perform किया जाता है। 

Syntex:

method को किसी भी variable के साथ use करने के लिए dot ( . ) का use करते है।

Example:

add() : इस method का use हम set मे नए item को add करने के लिए करते है। 

🐍
add.py
Copy to clipboard
my_fruits = {"apple", "banana"}
my_fruits.add("cherry")
print(f"Set after adding 'cherry': {my_fruits}")

my_fruits.add("banana") # Adding a duplicate, set remains unchanged
print(f"Set after trying to add 'banana' again: {my_fruits}")

How to Remove set items in Hindi

🐍
join.py
Copy to clipboard
# Using remove()
my_colors = {"red", "green", "blue", "yellow"}
my_colors.remove("green")
print(f"Set after removing 'green': {my_colors}")

# Using discard()
my_numbers = {10, 20, 30, 40, 50}
my_numbers.discard(30)
print(f"Set after discarding 30: {my_numbers}")

# Using pop()
my_items = {"apple", "banana", "cherry"}
popped_item = my_items.pop()
print(f"Popped item: {popped_item}")
print(f"Set after pop(): {my_items}")

# Using clear()
my_data = {10, 20, 30}
my_data.clear()
print(f"Set after clear(): {my_data}")

How to Join Sets in Hindi

🐍
join.py
Copy to clipboard
# Using update()
my_set = {1, 2, 3}
other_set = {3, 4, 5}
my_set.update(other_set)
print(f"Set after update(): {my_set}")

# Using union() 
my_set.union(other_set)
print(f"Set after union(): {my_set}")

intersection(): दो sets का intersection return करता है। 

difference(): दो sets का difference return करता है।

symmetric_difference(): दो sets का symmetric difference return करता है।

issubset(): Check करता है की एक set दूसरे set का subset है या नहीं।

issuperset(): Check करता है की एक set दूसरे set का superset है या नहीं।

उम्मीद करते है कि आपको python set अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Add a comment...

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
File Pointer

Table of Contents All Chapters 1. File Pointer 2. File Pointer Methods      2.1. tell() Method      2.2....

File Handling

Table of Contents All Chapters 1. File Handling 2. Types of File 3. open() and close() Methods 4. File Modes...

Python Modules

Table of Contents All Chapters 1. Modules in Python 2. Pre-defined Modules      2.1. math      2.2. random...

Python Iterators

Table of Contents All Chapters 1. Iterators      1.1. Iterable      1.2. Iterator      1.3. Iterator Protocol...

Python Polymorphism

Table of Contents All Chapters 1. Polymorphism 2. Key Concepts of Polymorphism 3. Types of Polymorphism      3.1. Polymorphism...

Python Inheritance

Table of Contents All Chapters 1. Inheritance 2. Concepts of Inheritance 3. Types of Inheritance      3.1. Single Inheritance...

Python Function

Table of Contents All Chapters 1. Python Function 2. Define Function 3. Function Arguments 4. Function Parameters 5. Local and...

Python Dictionary

Table of Contents All Chapters 1. Python Dictionary 2. Access Dictionary items 3. Change Dictionary items 4. Add items in...

Edit Template
Scroll to Top