Skip to content

Commit 9bfab09

Browse files
author
OverzealousLotus
committed
See v0.0.1b2
1 parent 4f90bc0 commit 9bfab09

24 files changed

Lines changed: 266 additions & 260 deletions

Python/.flake8

Lines changed: 0 additions & 2 deletions
This file was deleted.

Python/Examples/Threading/threadlocking.py renamed to Python/Examples/Advanced/Threading/threadlocking.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818

1919

20-
def fruit_sell():
20+
def fruit_sell() -> None:
2121
"""Where our fruit is sold."""
2222
global credits, threadlock, open
2323
if open == "YES":
@@ -40,24 +40,24 @@ def fruit_sell():
4040
print("")
4141

4242

43-
def shop():
43+
def shop() -> None:
4444
"""Where user can purchase items."""
45-
global credits, threadlock, open, USER_CHOICE, user_items, shop_items
45+
global credits, threadlock, open, user_choice, user_items, shop_items
4646
while True:
4747
if open == "YES":
4848
threadlock.acquire()
4949

50-
USER_CHOICE = str(input(" \nPlease choose from these items:")).upper()
50+
user_choice = str(input(" \nPlease choose from these items:")).upper()
5151
print("Otherwise, type anything to cancel.")
5252

53-
if USER_CHOICE == "UMBRELLA":
53+
if user_choice == "UMBRELLA":
5454
user_items.append("Umbrella")
5555
shop_items.pop("Umbrella")
5656
credits -= 10
57-
elif USER_CHOICE == "CANDY":
57+
elif user_choice == "CANDY":
5858
user_items.append("Candy")
5959
shop_items.pop("Candy")
60-
elif USER_CHOICE == "WHEELS":
60+
elif user_choice == "WHEELS":
6161
user_items.append("Wheels")
6262
shop_items.pop("Wheels")
6363
else:

Python/Examples/Threading/threads.py renamed to Python/Examples/Advanced/Threading/threads.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from time import sleep
55

66

7-
def fruit_gen():
7+
def fruit_gen() -> None:
88
"""Fruit generation."""
99
while True:
1010
our_fruit = choice([
@@ -27,7 +27,7 @@ def fruit_gen():
2727
print(f"One of our {our_fruit}s has been sold!")
2828

2929

30-
def income():
30+
def income() -> None:
3131
"""Our income gain."""
3232
increase: int = 1
3333
while True:
@@ -36,7 +36,7 @@ def income():
3636
print(f"You have gained ₼{increase} from selling fruits.")
3737

3838

39-
def time():
39+
def time() -> None:
4040
"""Our time passing."""
4141
days: int = 0
4242
while True:

Python/Examples/Async/async.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

Python/Examples/Beginner/arithmetic.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Math functions"""
1+
"""Mathematics in Python."""
22

33
__all__ = ["main"]
44
__version__ = "0.1"
@@ -7,10 +7,9 @@
77
import math # Importing math
88

99

10-
def main():
10+
def main() -> None:
1111
"""Function used to run entire program."""
12-
13-
pie: float = 3.13
12+
pie: float = 3.14
1413
xanther: int = 1
1514
yankee: int = 2
1615
zulu: int = 3
@@ -24,22 +23,22 @@ def main():
2423
# Rounds downwards
2524
print(math.floor(pie))
2625

27-
# Notifies Python how far a value is from zero
26+
# Notifies Python how far a value is from zero.
2827
print(abs(pie))
2928

30-
# Raises a value to a given power
29+
# Raises a value to a given power.
3130
print(pow(pie, 2))
3231

33-
# Square roots a given value
32+
# Square roots a given value.
3433
print(math.sqrt(pie))
3534

36-
# Cube roots a given valsue
35+
# Cube roots a given value.
3736
print(math.cbrt(pie))
3837

39-
# Searches for the highest value
38+
# Searches for the highest value.
4039
print(max(xanther, yankee, zulu))
4140

42-
# Searches for the lowest value
41+
# Searches for the lowest value.
4342
print(min(xanther, yankee, zulu))
4443

4544

Python/Examples/Beginner/builtins.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
"Built-in functions for Python"
1+
"""Built-in functions for Python."""
22

33
__all__ = ["main"]
44
__version__ = "0.1"
55
__author__ = "Overzealous Lotus"
66

77

8-
def main():
8+
def main() -> None:
99
"""Function to run our program."""
10-
1110
# Input()
1211

1312
# We ask the user their name.

Python/Examples/Beginner/control_flow.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
__author__ = "Overzealous Lotus"
77

88

9-
def main_if():
9+
def main_if() -> None:
1010
""" Function to run entire program."""
1111

12-
# if statement
12+
# <===| If |===>
1313

1414
age: int = int(input("How old are you?:"))
1515

16-
if age >= 100:
16+
if age >= 100: # If statements ask if something is true.
1717
print("You are an elderly.")
18-
elif age >= 18: # An if statement, asking a question. Only runs if true.
18+
elif age >= 18: # Elif statements only ask if something is true, if the previous is false.
1919
print("Wow! You are an adult!")
20-
elif age < 0: # If its parent statement(s) are false, then this will run.
20+
elif age < 0: # Second Elif statement.
2121
print("You have not been born yet. Weirdo.")
22-
else: # Asks if its parent statements are all false. Only runs if true.
22+
else: # If everything fails, Else is a fallback.
2323
print("You are an adolescent.")
2424

2525
temp: int = int(input("What is the temperature outside?: "))
@@ -32,54 +32,55 @@ def main_if():
3232
elif temp is False:
3333
print("Wow! The temperature is exactly zero!")
3434

35-
# "is" simply asks if something is something
35+
# "is" simply asks if something is something.
3636

37-
# Matching
37+
# <===| Matching |===>
3838

39-
# Alternatively to elif, we can use match cause statements
40-
41-
match age:
39+
# Alternatively, Match statements are shorthand syntax for Elif blocks.
40+
# They can save us space as developers, since programs can get big fast.
41+
match age: # Matches different values for "age"
4242
case 100 if age >= 100:
4343
print("Stop being old.")
4444
case 18 if age >= 18:
4545
print("You are LEGALLY an adult.")
4646
case 0 if age < 0:
4747
print("Okay, time-traveler.")
48-
case _: # _ is a placeholder
48+
case _: # _ is a placeholder. This case is a fallback.
4949
print("I don't know what that means.")
5050

5151

52-
def main_looping():
52+
def main_looping() -> None:
5353
"""Second function to run program. ( Loops )"""
5454

5555
name: str = ""
5656

57+
# <===| While |===>
5758
while not name: # Freezes program until input is given
5859
name = str(input("What is your name?: "))
5960

6061
print(f"Hello, {name}")
6162

62-
# for loop
63+
# <===| For |===>
6364

64-
for i in range(10): # Here, we tell Python to count up to 10.
65-
print(i + 1)
65+
for index in range(10): # Here, we tell Python to count up to 10.
66+
print(index + 1)
6667

67-
for i in range(50, 100 + 1, 2): # Python will count from 50, to 100.
68-
print(i)
68+
for index in range(50, 100 + 1, 2): # Python will count from 50, to 100.
69+
print(index)
6970

70-
for i in "Joshua Salas": # Prints every char in our name
71-
print(i)
71+
for index in "Joshua Salas": # Prints every char in our name
72+
print(index)
7273

7374
for seconds in range(10, 0, -1): # How about we count backwards now?
7475
print(seconds)
7576
sleep(1)
7677
print("Happy new year.")
7778

7879

79-
def main_control():
80+
def main_control() -> None:
8081
"""Tertiary function to run program. ( Loop Control )"""
8182

82-
# Nesting Loops/Statements
83+
# <===| Nesting |===>
8384

8485
rows: int = int(input("How many rows?: "))
8586
columns: int = int(input("How many columns?: "))
@@ -90,7 +91,7 @@ def main_control():
9091
print(symbol, end="") # Stops from printing to new line
9192
print()
9293

93-
# Controlling Loops
94+
# <===| Loop Control |===>
9495

9596
while True:
9697
name = str(input("Enter your name: "))

Python/Examples/Beginner/functions.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
__author__ = "Overzealous Lotus"
66

77

8-
def main():
8+
def main() -> None:
99
"""Primary function of our program."""
10-
11-
# pylint: disable=unnecessary-lambda
12-
1310
# To define functions in Python, we use the "def" keyword, then our function name.
1411
# Below, we can see a few things going on in our function. In parenthesis, they list-
1512
# -expected values to be inputed when this function is called. Without them, our func-
@@ -18,7 +15,6 @@ def addition(
1815
xanther: int | float,
1916
yankee: int | float) -> int | float:
2017
"""Always add Docstrings to your functions."""
21-
2218
return xanther + yankee # The "return" keyword returns our value.
2319

2420
print(addition(24.5, 24.5))

Python/Examples/Beginner/strings.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)