diff --git a/03_Day_Operators/03_operators.md b/03_Day_Operators/03_operators.md index 0fcfeb99..987a1180 100644 --- a/03_Day_Operators/03_operators.md +++ b/03_Day_Operators/03_operators.md @@ -75,7 +75,7 @@ print('Division: ', 7 / 2) # 3.5 print('Division without the remainder: ', 7 // 2) # 3, gives without the floating number or without the remaining print ('Division without the remainder: ',7 // 3) # 2 print('Modulus: ', 3 % 2) # 1, Gives the remainder -print('Exponentiation: ', 2 ** 3) # 9 it means 2 * 2 * 2 +print('Exponentiation: ', 2 ** 3) # 8 it means 2 * 2 * 2 ``` **Example:Floats** diff --git a/03_Day_Operators/day-3.py b/03_Day_Operators/day-3.py index b1402885..c984a82c 100644 --- a/03_Day_Operators/day-3.py +++ b/03_Day_Operators/day-3.py @@ -10,7 +10,7 @@ print('Division without the remainder: ', 7 // 2) # gives without the floating number or without the remaining print('Modulus: ', 3 % 2) # Gives the remainder print ('Division without the remainder: ', 7 // 3) -print('Exponential: ', 3 ** 2) # it means 3 * 3 +print('Exponential: ', 2 ** 3) # 8 it means 2 * 2 * 2 # Floating numbers print('Floating Number,PI', 3.14) diff --git a/07_Day_Sets/07_sets.md b/07_Day_Sets/07_sets.md index 3c61dd07..52b18e5a 100644 --- a/07_Day_Sets/07_sets.md +++ b/07_Day_Sets/07_sets.md @@ -226,7 +226,7 @@ fruits = set(fruits) # {'mango', 'lemon', 'banana', 'orange'} ### Joining Sets -We can join two sets using the _union()_ or _update()_ method. +We can join two sets using the _union()_ or _update()_ method or _|_ symbol . - Union This method returns a new set @@ -235,7 +235,7 @@ We can join two sets using the _union()_ or _update()_ method. # syntax st1 = {'item1', 'item2', 'item3', 'item4'} st2 = {'item5', 'item6', 'item7', 'item8'} -st3 = st1.union(st2) +st3 = st1.union(st2) #st3 = st1 | st2 ``` **Example:** @@ -244,6 +244,7 @@ st3 = st1.union(st2) fruits = {'banana', 'orange', 'mango', 'lemon'} vegetables = {'tomato', 'potato', 'cabbage','onion', 'carrot'} print(fruits.union(vegetables)) # {'lemon', 'carrot', 'tomato', 'banana', 'mango', 'orange', 'cabbage', 'potato', 'onion'} +# or using this : print(fruits | vegetables) ``` - Update @@ -267,13 +268,14 @@ print(fruits) # {'lemon', 'carrot', 'tomato', 'banana', 'mango', 'orange', 'cabb ### Finding Intersection Items -Intersection returns a set of items which are in both the sets. See the example +Intersection returns a set of items which are in both the sets or using _&_ symbol. See the example ```py # syntax st1 = {'item1', 'item2', 'item3', 'item4'} st2 = {'item3', 'item2'} st1.intersection(st2) # {'item3', 'item2'} +# or using thia : st1 & st2 ``` **Example:** @@ -286,6 +288,7 @@ whole_numbers.intersection(even_numbers) # {0, 2, 4, 6, 8, 10} python = {'p', 'y', 't', 'h', 'o','n'} dragon = {'d', 'r', 'a', 'g', 'o','n'} python.intersection(dragon) # {'o', 'n'} +# python & dragon ``` ### Checking Subset and Super Set @@ -318,14 +321,14 @@ python.issubset(dragon) # False ### Checking the Difference Between Two Sets -It returns the difference between two sets. +It returns the difference between two sets or using _-_ symbol . ```py # syntax st1 = {'item1', 'item2', 'item3', 'item4'} st2 = {'item2', 'item3'} -st2.difference(st1) # set() -st1.difference(st2) # {'item1', 'item4'} => st1\st2 +st2.difference(st1) # set() : st2 - st1 +st1.difference(st2) # {'item1', 'item4'} => st1\st2 : st2 - st1 ``` **Example:** @@ -338,19 +341,21 @@ whole_numbers.difference(even_numbers) # {1, 3, 5, 7, 9} python = {'p', 'y', 't', 'o','n'} dragon = {'d', 'r', 'a', 'g', 'o','n'} python.difference(dragon) # {'p', 'y', 't'} - the result is unordered (characteristic of sets) +# python - dragon dragon.difference(python) # {'d', 'r', 'a', 'g'} +# dragon - python ``` ### Finding Symmetric Difference Between Two Sets -It returns the symmetric difference between two sets. It means that it returns a set that contains all items from both sets, except items that are present in both sets, mathematically: (A\B) ∪ (B\A) +It returns the symmetric difference between two sets. It means that it returns a set that contains all items from both sets, except items that are present in both sets, mathematically: (A\B) ∪ (B\A) or using _^_ symbol ```py # syntax st1 = {'item1', 'item2', 'item3', 'item4'} st2 = {'item2', 'item3'} # it means (A\B)∪(B\A) -st2.symmetric_difference(st1) # {'item1', 'item4'} +st2.symmetric_difference(st1) # {'item1', 'item4'} : st2 ^ st1 ``` **Example:** @@ -363,6 +368,7 @@ whole_numbers.symmetric_difference(some_numbers) # {0, 6, 7, 8, 9, 10} python = {'p', 'y', 't', 'h', 'o','n'} dragon = {'d', 'r', 'a', 'g', 'o','n'} python.symmetric_difference(dragon) # {'r', 't', 'p', 'y', 'g', 'a', 'd', 'h'} +# python ^ dragon ``` ### Joining Sets diff --git a/10_Day_Loops/10_loops.md b/10_Day_Loops/10_loops.md index f03265a9..f8a98344 100644 --- a/10_Day_Loops/10_loops.md +++ b/10_Day_Loops/10_loops.md @@ -302,6 +302,10 @@ lst = list(range(0,11,2)) print(lst) # [0, 2, 4, 6, 8, 10] st = set(range(0,11,2)) print(st) # {0, 2, 4, 6, 8, 10} + +# for backward from start to end +lst = list(range(11,0,-2)) +print(lst) # [11,9,7,5,3,1] ``` ```py diff --git a/11_Day_Functions/11_functions.md b/11_Day_Functions/11_functions.md index 2a0ad39b..adb308c2 100644 --- a/11_Day_Functions/11_functions.md +++ b/11_Day_Functions/11_functions.md @@ -369,7 +369,7 @@ def square_number (n): return n * n def do_something(f, x): return f(x) -print(do_something(square_number, 3)) # 27 +print(do_something(square_number, 3)) # 9 ``` 🌕 You achieved quite a lot so far. Keep going! You have just completed day 11 challenges and you are 11 steps a head in to your way to greatness. Now do some exercises for your brain and muscles.