SET IN PYTHON IN HINDI

Python Set in hindi | set in python with examples in hindi

Python

Python Set Funciton in Hindi – Set Ek Data Type hai unordered collecetion of unique items | set me kuch bhi data store kar sakte hai lekin list , dict , tuple store nhi kar sakte hai |

Sets ka kiya fayda hai :- Set ham python me isliye istemal karte hai taki kisi bhi duplicate ko ek baar print kara sake |

Python Set in Hindi

Set in python ko Or Accha Samanjh ne ke liye iske A To Z example dekhte |

Python Create set

Syntax :

 { Curly braces }  

Aap upper diye gye syntax ko dekh sakte hai.

SET IN PYTHON IN HINDI

How To Create python set

Example 1 :-

data  = {1,2,3,4}
print(data)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

{1, 2, 3, 4} 

Aap upper Diye gye output ko dekh kar program ko samanjh sakte hai.

Sets In Python

Example 2 :-

data  = {1,2,3,4,5,5,6,6,7,9,10}
for i in data:     
    print(i)

Program me upper dekh sakte hai ki hamne 5 ,5 & 6 ,6 do baar liya hai lekin output me ye ek hi bar print hoga ye hi set ka fayda hai|

Output :-

1
2
3
4
6
7
9
10

Aap Upper Diye gye output ko dekh kar program ko samanjh sakte hai.

python set add()

Example 3:-

data  = {1,2,3,4}
data.add(5)    # add data
print(data)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

{1,2,3,4,5)

Aap upper Diye gye output ko dekh kar program ko samanjh sakte hai.

Python Dictionary Indexing

Set Me Aap Indexing Nhi Kar Sakte hai Kyoki set unordered collection of unique items hai | Aap Example 4 me Dekh Skate hai iska program |

Example 4:-

data  = {1,2,3,4,5}
print(data[0])

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

Traceback (most recent call last):                                                                                            
  File "main.py", line 2, in <module>                                                                                         
    print(data[0])                                                                                                            
TypeError: 'set' object does not support indexing 

Aap Dekh Sakte hai Program Error kyoki aap set me indexing nhi kar sakte hai |

how to set remove items

Example 5:-

data  = {1,2,3,4,5}     #  set

data.remove(1)    # remove data 
     
print(data)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

{2, 3, 4, 5} 

Aap upper Diye gye output ko dekh kar program ko samanjh sakte hai |

python Set in keyword

Agar Hame Ye Pata Karna Ho Ki Hamara set me item hai Ya nhi to ye is example 6 me dekhte hai using in keyword |

Example 6:-

data  = {1,2,3,4,5,6,7,'danish',3.14}

if 'danish' in data:            # find items
      print('present')
else:
     print('Not Present')
     

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

present

Aap upper Diye gye output ko dekh kar program ko samanjh sakte hai |

Clear Method In Set In Python

Clear Method set ko clear ka karta hai , Aap Example 7 dekh sakte hai |

Example 7:-

data  = {1,2,3,4,5,6 }


# clear mathod

data.clear()

print(data)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

set()

Aap upper Diye gye clear method ke output ko dekh kar program ko samanjh sakte hai |

python copy function

Example 8:-

data1  = {1,2,3,4,5,6}
data2 = data1.copy()
print(data2)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

{1, 2, 3, 4, 5, 6} 

Aap upper Diye gye copy() function ke output ko dekh kar program ko samanjh sakte hai |

Math Logical Function in set

Python set me 2 math logical function istemal karte hai |

  1. Union |
  2. Intersection &

Union Example 9:-

Union matlab agar 2 set me ek hi tarah ke number hai wo ek hi baar print honge |

data1  = {1,2,3,4}
data2  = {3,4,5,6}

union_set = data1 | data2

print(union_set)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

{1, 2, 3, 4, 5, 6}

Aap upper Diye gye union Function ke output ko dekh kar program ko samanjh sakte hai |

Intersection Example 10:-

Intersection matlab agar 2 set me ek hi tarah ke number hai wo hi print honge |

data1  = {1,2,3,4}
data2  = {3,4,5,6}

intersection_set = data1 & data2

print(intersection_set)

Aap Upper Diye Gye Program ko samanjh sakte hai.

Output :-

{3, 4}

Aap upper Diye gye Intersection Function ke output ko dekh kar program ko samanjh sakte hai |

Python Set in hindi | set in python with examples in hindi

Also Read This Post :

Dosto mujhe ummed hai ki aap set in python with examples ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |

Leave a Reply

Your email address will not be published. Required fields are marked *