diff --git a/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/arrays.py b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/arrays.py new file mode 100644 index 0000000..078626c --- /dev/null +++ b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/arrays.py @@ -0,0 +1,18 @@ +import datetime + +def calculate_age(dateOfBirth): + today = datetime.datetime.now() + age = today.year - dateOfBirth.year - ((today.month, today.day) < (dateOfBirth.month, dateOfBirth.day)) + return age + +def print_result(age): + if age >= 18: + print("You are " + str(age) + "! Enjoy the film") + else: + print("Sorry you aren't old enough you are only " + str(age)) + +datesOfBirth = [datetime.datetime(1995, 9, 20), datetime.datetime(1996, 12, 2)] +age = calculate_age(dateOfBirth) + +print_result(age) + diff --git a/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/for-loops.py b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/for-loops.py new file mode 100644 index 0000000..080c794 --- /dev/null +++ b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/for-loops.py @@ -0,0 +1,18 @@ +import datetime + +def calculate_age(dateOfBirth): + today = datetime.datetime.now() + age = today.year - dateOfBirth.year - ((today.month, today.day) < (dateOfBirth.month, dateOfBirth.day)) + return age + +def print_result(age): + if age >= 18: + print("You are " + str(age) + "! Enjoy the film") + else: + print("Sorry you aren't old enough you are only " + str(age)) + +datesOfBirth = [datetime.datetime(1995, 9, 20), datetime.datetime(1996, 12, 2)] + +for dateOfBirth in datesOfBirth: + age = calculate_age(dateOfBirth) + print_result(age) \ No newline at end of file diff --git a/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/functions.py b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/functions.py new file mode 100644 index 0000000..8eae9d6 --- /dev/null +++ b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/functions.py @@ -0,0 +1,17 @@ +import datetime + +def calculate_age(dateOfBirth): + today = datetime.datetime.now() + age = today.year - dateOfBirth.year - ((today.month, today.day) < (dateOfBirth.month, dateOfBirth.day)) + return age + +def print_result(age): + if age >= 18: + print("You are " + str(age) + "! Enjoy the film") + else: + print("Sorry you aren't old enough you are only " + str(age)) + +dateOfBirth = datetime.datetime(1995, 9, 20) +age = calculate_age(dateOfBirth) + +print_result(age) \ No newline at end of file diff --git a/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/if-statements.py b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/if-statements.py new file mode 100644 index 0000000..fab6555 --- /dev/null +++ b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/if-statements.py @@ -0,0 +1,12 @@ +import datetime + +dateOfBirth = datetime.datetime(1990, 9, 20) +today = datetime.datetime.now() + +age = today.year - dateOfBirth.year - ((today.month, today.day) < (dateOfBirth.month, dateOfBirth.day)) + +print(age) +if age >= 18: + print("Enjoy the film") +else: + print("Sorry you aren't old enough") \ No newline at end of file diff --git a/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/variables.py b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/variables.py new file mode 100644 index 0000000..c7feb4b --- /dev/null +++ b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/variables.py @@ -0,0 +1,11 @@ +import datetime + +def calculate_age(dateOfBirth): + today = datetime.datetime.now() + age = today.year - dateOfBirth.year - ((today.month, today.day) < (dateOfBirth.month, dateOfBirth.day)) + return age + +dateOfBirth = datetime.datetime(1990, 9, 20) +age = calculate_age(dateOfBirth) + +print(age) \ No newline at end of file diff --git a/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/while-loops.py b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/while-loops.py new file mode 100644 index 0000000..7aea1c2 --- /dev/null +++ b/2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners/while-loops.py @@ -0,0 +1,5 @@ +i = 1 + +while i <= 5: + print(i) + i = i + 1 \ No newline at end of file diff --git a/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/and.py b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/and.py new file mode 100644 index 0000000..58220dc --- /dev/null +++ b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/and.py @@ -0,0 +1,13 @@ +READ_PERMISSION = 4 +WRITE_PERMISSION = 2 +EXECUTE_PERMISSION = 1 + +userPermissions = 6 + +if (userPermissions & READ_PERMISSION) == READ_PERMISSION: + print("Can Read") +else: + print("Cannot Read") + +print(userPermissions & READ_PERMISSION) +print(bin(userPermissions & READ_PERMISSION)) diff --git a/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/left.py b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/left.py new file mode 100644 index 0000000..99caaa6 --- /dev/null +++ b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/left.py @@ -0,0 +1,9 @@ +number = 5 + +print(number) +print(bin(number)) + +number = number << 2 + +print(number) +print(bin(number)) \ No newline at end of file diff --git a/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/not.py b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/not.py new file mode 100644 index 0000000..a092fec --- /dev/null +++ b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/not.py @@ -0,0 +1,9 @@ +number = 5 + +print(number) +print(bin(number)) + +number = ~number + +print(number) +print(bin(number)) \ No newline at end of file diff --git a/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or.py b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or.py new file mode 100644 index 0000000..8b33857 --- /dev/null +++ b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or.py @@ -0,0 +1,8 @@ +READ_PERMISSION = 4 +WRITE_PERMISSION = 2 +EXECUTE_PERMISSION = 1 + +userPermissions = READ_PERMISSION | WRITE_PERMISSION + +print(userPermissions) +print(bin(userPermissions)) diff --git a/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or2.py b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or2.py new file mode 100644 index 0000000..fc132fd --- /dev/null +++ b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or2.py @@ -0,0 +1,10 @@ +READ_PERMISSION = 4 +WRITE_PERMISSION = 2 +EXECUTE_PERMISSION = 1 + +userPermissions = READ_PERMISSION | WRITE_PERMISSION + +userPermissions |= EXECUTE_PERMISSION + +print(userPermissions) +print(bin(userPermissions)) \ No newline at end of file diff --git a/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/right.py b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/right.py new file mode 100644 index 0000000..b6dd000 --- /dev/null +++ b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/right.py @@ -0,0 +1,14 @@ +number = 5 + +print(number) +print(bin(number)) + +number = number << 2 + +print(number) +print(bin(number)) + +number = number >> 2 + +print(number) +print(bin(number)) \ No newline at end of file diff --git a/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/xor.py b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/xor.py new file mode 100644 index 0000000..ef4002d --- /dev/null +++ b/2022-10-21-Bitwise-Operators-and-WHY-we-use-them/xor.py @@ -0,0 +1,10 @@ +READ_PERMISSION = 4 +WRITE_PERMISSION = 2 +EXECUTE_PERMISSION = 1 + +userPermissions = READ_PERMISSION | WRITE_PERMISSION + +userPermissions ^= WRITE_PERMISSION + +print(userPermissions) +print(bin(userPermissions)) \ No newline at end of file diff --git a/move-photos.py b/2022-11-11-Automate-Your-Life-With-Python/move-photos.py similarity index 100% rename from move-photos.py rename to 2022-11-11-Automate-Your-Life-With-Python/move-photos.py diff --git a/README.md b/README.md index d024566..c80025b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ -# youtube-code -This repository contains all the code from my YouTube videos. +# Code featured in YouTube videos +Thank you 🙏🏻 for becoming a sponsor ❤️. I really do appreciate your support. -## Index -- [Automate Your Life With Python (File Management Step By Step Example)](https://youtu.be/1dgnl7oCVTY) - [move-photos.py](move-photos.py) +This repository contains all the code from my YouTube videos. Unfortunately GitHub sponsors doesn't yet allow me to assign multiple repositories for sponsors. If they do in the future I might split this repository up a bit. + +## Index of all the code by YouTube video and date +I will add new code as soon as I am done with the video. So you might find the latest on this video hasn't been released yet. + +- [2022-11-11 Automate Your Life With Python (File Management Step By Step Example)](https://youtu.be/1dgnl7oCVTY) - [code](2022-11-11-Automate-Your-Life-With-Python/move-photos.py) +- [2022-10-21 Bitwise Operators and WHY we use them](https://youtu.be/igIjGxF2J-w) - [code](2022-10-21-Bitwise-Operators-and-WHY-we-use-them) +- [2022-10-10 6 Coding Concepts You MUST Know For Beginners](https://youtu.be/pKFcVs2HibA) - [code](2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners)