Python Set
Table of Contents All Chapters 1. Python Set 2. Iterate Set items 3. Set Methods ┬а ┬а ┬а3.1. Add items in Set ┬а ┬а ┬а3.2. Remove Set items ┬а ┬а ┬а2.3.┬а Join Sets ┬а Python Tutorial Python Introduction Identation & Comments Python Variable Python Data Type Python Operators Conditional Statements Python Loops Python String Python List Python Tuple Hamburger Toggle Menu Table of Contents 1. Python Set 2. Iterate Set items 3. Set Methods ┬а ┬а ┬а3.1. Add items in Set ┬а ┬а ┬а3.2. Remove Set items ┬а ┬а ┬а2.3.┬а Join Sets 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 1 2 3 4 5 6 7 8 9 10 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 1 2 3 4 5 6 7 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 1 2 3 4 5 6 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 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # remove() my_colors = {"red", "green", "blue", "yellow"} my_colors.remove("green") print(f"Set after removing 'green': {my_colors}") # discard() my_numbers = {10, 20, 30, 40, 50} my_numbers.discard(30) print(f"Set after discarding 30: {my_numbers}") # pop() my_items = {"apple", "banana", "cherry"} popped_item = my_items.pop() print(f"Popped item: {popped_item}") print(f"Set after pop(): {my_items}") # 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 1 2 3 4 5 6 my_set = {1, 2, 3} other_set = {3, 4, 5} my_set.update(other_set) print(f"Set after update(): {my_set}") my_set.union(other_set) print(f"Set after union(): {my_set}") intersection(): Do sets ka intersection return karta hai. difference(): Do sets ka difference return karta hai. symmetric_difference(): Do sets ka symmetric difference return karta hai. issubset(): Check karta hai ki ek set dusre set ka subset hai ya nahi. issuperset(): Check karta hai ki ek set dusre set ka superset hai ya nahi. рдЙрдореНрдореАрдж рдХрд░рддреЗ рд╣реИ рдХрд┐ рдЖрдкрдХреЛ python set рдЕрдЪреНрдЫреЗ рд╕рдордЭ рдореЗ рдЖ рдЧрдпрд╛ рд╣реЛрдЧрд╛ ред рдЕрдкрдиреЗ learning рдХреЛ continue рд░рдЦрдиреЗ рдХреЗ рд▓рд┐рдП next button рдкрд░ click рдХрд░реЗ, Previous Next Add a comment… Cancel Reply Logged in as Python Programming Hub. Edit your profile. Log out? Required fields are marked * Message*