Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit f33ab46

Browse files
✨ Sets
1 parent 2e68414 commit f33ab46

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

β€Ž11_Sets/01_sets.pyβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Check if "apple" is present in the fruits set.
2+
fruits = {"apple", "banana", "cherry"}
3+
if "apple" in fruits:
4+
print("Yes, apple is a fruit!")

β€Ž11_Sets/02_sets.pyβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Use the add method to add "orange" to the fruits set.
2+
fruits = {"apple", "banana", "cherry"}
3+
fruits.add("orange")
4+
print(fruits)

β€Ž11_Sets/03_sets.pyβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Use the correct method to add multiple items (more_fruits) to the fruits set.
2+
fruits = {"apple", "banana", "cherry"}
3+
more_fruits = ["orange", "mango", "grapes"]
4+
fruits.update(more_fruits)
5+
print(fruits)

β€Ž11_Sets/04_sets.pyβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Use the remove method to remove "banana" from the fruits set.
2+
fruits = {"apple", "banana", "cherry"}
3+
fruits.remove("banana")
4+
5+
print(fruits)

β€Ž11_Sets/05_sets.pyβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Use the discard method to remove "banana" from the fruits set.
2+
3+
fruits = {"apple", "banana", "cherry"}
4+
fruits.discard("banana")
5+
6+
print(fruits)

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /