Add code from other videos
This commit is contained in:
parent
ed1f64dcf8
commit
aefb6e4152
15 changed files with 164 additions and 4 deletions
|
@ -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)
|
||||
|
|
@ -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)
|
|
@ -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)
|
|
@ -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")
|
|
@ -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)
|
|
@ -0,0 +1,5 @@
|
|||
i = 1
|
||||
|
||||
while i <= 5:
|
||||
print(i)
|
||||
i = i + 1
|
13
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/and.py
Normal file
13
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/and.py
Normal file
|
@ -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))
|
9
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/left.py
Normal file
9
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/left.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
number = 5
|
||||
|
||||
print(number)
|
||||
print(bin(number))
|
||||
|
||||
number = number << 2
|
||||
|
||||
print(number)
|
||||
print(bin(number))
|
9
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/not.py
Normal file
9
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/not.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
number = 5
|
||||
|
||||
print(number)
|
||||
print(bin(number))
|
||||
|
||||
number = ~number
|
||||
|
||||
print(number)
|
||||
print(bin(number))
|
8
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or.py
Normal file
8
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
READ_PERMISSION = 4
|
||||
WRITE_PERMISSION = 2
|
||||
EXECUTE_PERMISSION = 1
|
||||
|
||||
userPermissions = READ_PERMISSION | WRITE_PERMISSION
|
||||
|
||||
print(userPermissions)
|
||||
print(bin(userPermissions))
|
10
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or2.py
Normal file
10
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/or2.py
Normal file
|
@ -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))
|
14
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/right.py
Normal file
14
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/right.py
Normal file
|
@ -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))
|
10
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/xor.py
Normal file
10
2022-10-21-Bitwise-Operators-and-WHY-we-use-them/xor.py
Normal file
|
@ -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))
|
14
README.md
14
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)
|
||||
|
|
Loading…
Reference in a new issue