-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 88a273f
Showing
204 changed files
with
269,469 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.DS_Store/ | ||
.git/ | ||
bin/ | ||
etc/ | ||
lib/ | ||
include/ | ||
share/ | ||
pyvenv.cfg | ||
__pycache__/ | ||
.pytest_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print("Hello Python world!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
message = "Hello Python World!" | ||
print(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
message = "Hello Python World!" | ||
print(message) | ||
|
||
message = "Bye Python World!" | ||
print(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
firstName = "Jay" | ||
lastName = "Chou" | ||
|
||
name = f"{firstName} {lastName}" | ||
|
||
print(f"Hello {name}, would you like to learn some Python today?") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
firstName = "Jay" | ||
lastName = "Chou" | ||
|
||
name = f"{firstName} {lastName}" | ||
|
||
print(f"Hello {name.title()}, would you like to learn some Python today?") # Normal case | ||
print(f"Hello {name.lower()}, would you like to learn some Python today?") # Lower case | ||
print(f"Hello {name.upper()}, would you like to learn some Python today?") # Upper case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
firstName = "Jay" | ||
lastName = "Chou" | ||
|
||
name = f"{firstName} {lastName}" | ||
quote = "Ayo, not bad!" | ||
|
||
print(f'{name.title()} once said, "{quote}".') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
firstName = "Jay" | ||
lastName = "Chou" | ||
|
||
famous_person = f"{firstName} {lastName}" | ||
message = "Ayo, not bad!" | ||
|
||
|
||
print(f'{famous_person.title()} once said, "{message}".') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
firstName = "Jay" | ||
lastName = "Chou" | ||
|
||
name = f"\t{firstName} \n{lastName} " | ||
|
||
print(f"{name}") | ||
print(f"{name.strip()}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
filename = "python_notes.txt" | ||
|
||
filename = filename.removesuffix(".txt") | ||
|
||
print(f"{filename}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
print(1 + 7) | ||
print(8 - 0) | ||
print(1 * 8) | ||
print(8 // 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
f_num = 2 | ||
|
||
message = f"{f_num} is my favorite num!" | ||
|
||
print(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This is a single line comment | ||
|
||
""" | ||
This is a commit block. | ||
You can add more than two lines. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
>>> import this | ||
""" | ||
|
||
""" | ||
>>> import this | ||
The Zen of Python, by Tim Peters | ||
Beautiful is better than ugly. | ||
Explicit is better than implicit. | ||
Simple is better than complex. | ||
Complex is better than complicated. | ||
Flat is better than nested. | ||
Sparse is better than dense. | ||
Readability counts. | ||
Special cases aren't special enough to break the rules. | ||
Although practicality beats purity. | ||
Errors should never pass silently. | ||
Unless explicitly silenced. | ||
In the face of ambiguity, refuse the temptation to guess. | ||
There should be one-- and preferably only one --obvious way to do it. | ||
Although that way may not be obvious at first unless you're Dutch. | ||
Now is better than never. | ||
Although never is often better than *right* now. | ||
If the implementation is hard to explain, it's a bad idea. | ||
If the implementation is easy to explain, it may be a good idea. | ||
Namespaces are one honking great idea -- let's do more of those! | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
names = ['lil a', 'lil b', 'lil c', 'lil d'] | ||
|
||
print(names[0].title()) | ||
print(names[1].title()) | ||
print(names[2].title()) | ||
print(names[3].title()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
names = ['lil a', 'lil b', 'lil c', 'lil d'] | ||
|
||
greeting_message = "Nice to meet you." | ||
|
||
print(f"{names[0].title()}, {greeting_message.lower()}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
traffice_way = ['bicycle', 'bus', 'taxi', 'car'] | ||
print(f"I would like to buy my own {traffice_way[-1].lower()}.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
names = ['lil a', 'lil b', 'lil c', 'lil d'] | ||
|
||
print(f"Hey, {names[0].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[1].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[2].title()}, come to have dinner with me!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
names = ['lil a', 'lil b', 'lil c', 'lil d'] | ||
|
||
regret = names.pop(1) | ||
|
||
print(f"It is a pity that {regret.title()} can not make the appointment.") | ||
|
||
new_name = names.insert(1, 'big b') | ||
|
||
print(f"Hey, {names[0].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[1].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[2].title()}, come to have dinner with me!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
names = ['lil a', 'lil b', 'lil c', 'lil d'] | ||
|
||
regret = names.pop(1) | ||
|
||
print(f"It is a pity that {regret.title()} can not make the appointment.") | ||
|
||
names.insert(1, 'big b') | ||
|
||
print(f"Hey, {names[0].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[1].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[2].title()}, come to have dinner with me!") | ||
|
||
print("Congratulations! I found a bigger dinner table!") | ||
|
||
names.insert(0, 'big a') | ||
names.insert(3, 'big c') | ||
names[-1] = 'big d' | ||
names.append('lil d') | ||
|
||
print(f"Hey, {names[0].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[1].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[2].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[3].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[4].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[5].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[6].title()}, come to have dinner with me!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
names = ['lil a', 'lil b', 'lil c', 'lil d'] | ||
|
||
regret = names.pop(1) | ||
|
||
names.insert(1, 'big b') | ||
|
||
print("Congratulations! I found a bigger dinner table!") | ||
|
||
names.insert(0, 'big a') | ||
names.insert(3, 'big c') | ||
names[-1] = 'big d' | ||
names.append('lil d') | ||
|
||
print(f"Hey, {names[0].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[1].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[2].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[3].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[4].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[5].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[6].title()}, come to have dinner with me!") | ||
|
||
print("I can only invite two guests due to the suck AWS!") | ||
|
||
print(f"Sorry, {names.pop().title()}!") | ||
print(f"Sorry, {names.pop().title()}!") | ||
print(f"Sorry, {names.pop().title()}!") | ||
print(f"Sorry, {names.pop().title()}!") | ||
print(f"Sorry, {names.pop().title()}!") | ||
|
||
print(f"{names[0].title()}, you are still in my list.") | ||
print(f"{names[1].title()}, you are still in my list.") | ||
|
||
del names[0:] | ||
print(names) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
tourist_destinations = ['US', 'JP', 'UK', 'DE', 'FR'] | ||
print(tourist_destinations) | ||
|
||
print(sorted(tourist_destinations)) | ||
|
||
print(tourist_destinations) | ||
|
||
print(sorted(tourist_destinations, reverse=True)) | ||
|
||
print(tourist_destinations) | ||
|
||
tourist_destinations.reverse() | ||
print(tourist_destinations) | ||
""" | ||
The output of the command `print(tourist.destinations.reverse())` is `None`, due to reverse() returns nothing. | ||
If you want to write it in one line, you can use the reverse() method with a logical OR operator: | ||
``` | ||
print(tourist.destinations.reverse() or tourist.destinations) | ||
``` | ||
This method utilizes Python's short-circuit evaluation of the logical OR operator (or). Here's how it works: | ||
a. reverse() is called first. This method reverses the list a in-place and returns None. | ||
b. In Python, None is considered False in a boolean context. | ||
c. The or operator evaluates its left operand (a.reverse()). Since it's None (which is False), it moves on to evaluate the right operand (a). | ||
d. The right operand a is the reversed list, which is then returned and printed. | ||
""" | ||
|
||
tourist_destinations.reverse() | ||
print(tourist_destinations) | ||
|
||
tourist_destinations.sort() | ||
print(tourist_destinations) | ||
|
||
tourist_destinations.sort(reverse=True) | ||
print(tourist_destinations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
names = ['lil a', 'lil b', 'lil c', 'lil d'] | ||
|
||
print(f"Hey, {names[0].title()}, come to have dinner with me!") | ||
print(f"Hey, {names[1].title()}, come to have dinner with me!") | ||
|
||
print(f"I invited {len(names)} friends for my dinner.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tourist_destinations = ['US', 'JP', 'UK', 'DE', 'FR'] | ||
|
||
del tourist_destinations[0] | ||
|
||
len(tourist_destinations) | ||
|
||
sorted(tourist_destinations) | ||
|
||
print(tourist_destinations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
tourist_destinations = ['US', 'JP', 'UK', 'DE', 'FR'] | ||
|
||
# print(tourist_destinations[5]) | ||
print(tourist_destinations[3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pizzas = ['Neapolitan Pizza', 'New York-Style Pizza', | ||
'Chicago-Style Deep-Dish Pizza', 'California-Style Pizza', 'Sicilian-Style Pizza'] | ||
|
||
for pizza in pizzas: | ||
print(pizza) | ||
|
||
|
||
for pizza in pizzas: | ||
print(f"I like {pizza}.") | ||
|
||
print("I really love pizza!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
mammals = ['lion', 'panda', 'koala'] | ||
|
||
for mammal in mammals: | ||
print(f"A {mammal} would make a great pet.") | ||
|
||
print("Any of these animals is a mammal.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
for value in range(1, 21): | ||
print(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
million = list(range(1, 1_000_001)) | ||
for mil in million: | ||
print(mil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
million = list(range(1, 1_000_001)) | ||
|
||
print(min(million)) | ||
print(max(million)) | ||
print(sum(million)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
odd = list(range(1, 20, 2)) | ||
|
||
for oddodd in odd: | ||
print(oddodd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
threes = list(range(3, 31, 3)) | ||
|
||
for three in threes: | ||
print(three) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cubes = [] | ||
for i in range(1, 11): | ||
cubes.append(i ** 3) | ||
|
||
for cube in cubes: | ||
print(cube) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
cubes = [cube ** 3 for cube in range(1, 11)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pizzas = ['Neapolitan Pizza', 'New York-Style Pizza', | ||
'Chicago-Style Deep-Dish Pizza', 'California-Style Pizza', 'Sicilian-Style Pizza'] | ||
|
||
print("The first three items in the list are:") | ||
for i in pizzas[:3]: | ||
print(i) | ||
|
||
print("\nThree items from the middle of the list are:") | ||
for i in pizzas[1:4]: | ||
print(i) | ||
|
||
print("\nThe last three items in the list are:") | ||
for i in pizzas[-3:]: | ||
print(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pizzas = ['Neapolitan Pizza', 'New York-Style Pizza', | ||
'Chicago-Style Deep-Dish Pizza', 'California-Style Pizza', 'Sicilian-Style Pizza'] | ||
|
||
friend_pizza = pizzas[:] | ||
|
||
pizzas.append('Tokyo-Style Pizza') | ||
friend_pizza.append('Cypriot-Style Pizza') | ||
|
||
print("My favorite pizzas are:") | ||
for my in pizzas: | ||
print(my) | ||
|
||
print("\nMy friend's favorite pizzas are:") | ||
for friend in friend_pizza: | ||
print(friend) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
my_foods = ['pizza', 'falafel', 'carrot cake'] | ||
friend_foods = my_foods[:] | ||
|
||
print("My favorite foods are:") | ||
for my in my_foods: | ||
print(my) | ||
|
||
print("\nMy friend's favorite foods are:") | ||
for friend in friend_foods: | ||
print(friend) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
dishes = ("Fish and Chips", "Shepherd's Pie", "Caesar Salad", | ||
"Spaghetti Bolognese", "Chicken Curry") | ||
|
||
for dish in dishes: | ||
print(dish) | ||
|
||
# dishes[0] = "a" | ||
|
||
dishes = ("Fish and Chips", "Beef Wellington", | ||
"Caesar Salad", "Pad Thai", "Chicken Curry") | ||
print("\n") | ||
for dish in dishes: | ||
print(dish) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Read "PEP 8 - Styles Guide for Python Code". | ||
# https://peps.python.org/pep-0008/ |
Oops, something went wrong.