Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
"python.testing.pytestArgs": [],
"python.envFile": "${workspaceFolder}/.env",
"python.analysis.typeCheckingMode": "basic",
"svn.ignoreMissingSvnWarning": true,
}
5 changes: 5 additions & 0 deletions data/weather.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
date,low,high
10/16,56,75
10/17,57,76
10/18,62,75
10/19,64,79
4 changes: 4 additions & 0 deletions exercises/ex00_hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""My first program for COMP110."""
print("Hello to the World.")

__author__ = "730474722"
52 changes: 52 additions & 0 deletions exercises/ex01_chardle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""EX01 - Chardle - A cute step toward Wordle."""

__author__ = "730474722"

"""prompting for inputs"""
word: str = input("Enter a 5-character word: ")
if len(word) > 5:
print("Error: Word must contain 5 characters")
exit()
if len(word) < 5:
print("Error: Word must contain 5 characters")
exit()
character: str = input("Enter a single character: ")
if len(character) > 1:
print("Error: Character must be a single character.")
exit()
if len(character) < 1:
print("Error: Character must be a single character.")
exit()

"""exiting for invalid inputs"""

"""prompting for inputs continued"""
print("Searching for " + character + " in " + word)
match_maker = word.find(character, 0, 4)
if match_maker == 0:
print(character, "found at index 0")

'''checking indices for matches'''
match_maker = word.find(character, 1, 4)
if match_maker == 1:
print(character, "found at index 1")
match_maker = word.find(character, 2, 4)
if match_maker == 2:
print(character, "found at index 2")
match_maker = word.find(character, 3, 4)
if match_maker == 3:
print(character, "found at index 3")
match_maker = word.find(character, 4, 5)
if match_maker == 4:
print(character, "found at index 4")

"""counting matching indices"""
count: int = word.count(character)
if count == 0:
print("No instances of", character, "found in", word)
else:
if count == 1:
print(count, "instance of", character, "found in", word)
else:
if count > 1:
print(count, "instances of", character, "found in", word)
57 changes: 57 additions & 0 deletions exercises/ex02_one_shot_wordle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""One Shot Wordle!"""

__author__ = "730474722"

"""Providing the correct user input"""
secret: str = "ears"
intro: str = input(f"What is your {len(secret)}-letter guess? ")
proceed: bool = False
while (proceed is False):
if len(secret) != len(intro):
intro = input(f"That was not {len(secret)}-letters! Try again: ")
else:
proceed = True

WHITE_BOX: str = "\U00002B1C"
GREEN_BOX: str = "\U0001F7E9"
YELLOW_BOX: str = "\U0001F7E8"

current_index: int = 0
ci = current_index
scan = 0
g = GREEN_BOX
w = WHITE_BOX
y = YELLOW_BOX
emojis: str = ""
tracker: bool = False
tracker is False

"""Matching indexes when guess is incorrect"""
if intro != secret:
while ci < len(secret):
if intro[ci] == secret[ci]:
emojis += g
else:
while (not tracker) and (scan < len(secret)):
if intro[ci] == secret[scan]:
tracker = True
else:
scan += 1
if tracker is True:
emojis += y
else:
emojis += w
scan = 0
tracker = False
ci += 1
print(emojis)
print("Not quite. Play again soon!")


"""Win"""
if intro == secret:
while ci < len(secret):
emojis += g
ci += 1
print(emojis)
print("Woo! You got it!")
76 changes: 76 additions & 0 deletions exercises/ex03_wordle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""Wordle Baby!"""

__author__ = "730474722"


def contains_char(word: str, character: str) -> bool:
"""Scans for Matching Characters in a Word!"""
assert len(character) == 1
i: int = 0
p: int = 0
tracker: bool = False
while tracker is False and i < len(word):
if word[i] == character[p]:
tracker = True
else:
i += 1
return tracker


"""The boxes."""
WHITE_BOX: str = "\U00002B1C"
GREEN_BOX: str = "\U0001F7E9"
YELLOW_BOX: str = "\U0001F7E8"
g = GREEN_BOX
w = WHITE_BOX
y = YELLOW_BOX


def emojified(guess: str, secret: str) -> str:
"""Returns a Specific Emoji That Pertains to the Guess Index!"""
assert len(guess) == len(secret)
t: int = 0
emojis: str = ""
while t < len(secret):
if guess[t] == secret[t]:
emojis += g
elif contains_char(secret, guess[t]):
emojis += y
else:
emojis += w
t += 1
return emojis


def input_guess(guess: int) -> str:
"""Asks the User for a Guess Until len of Guess Matches len of the Secret!"""
attempt: str = input(f"Enter a {guess} character word: ")
if len(attempt) == guess:
return attempt
else:
while len(attempt) != guess:
attempt = input(f"That wasn't {guess} chars! Try again: ")
return attempt


def main() -> None:
"""The entrypoint of the program and main game loop."""
secret: str = "codes"
tries: int = 1
max_tries = 6
win: bool = False
win is False
while tries <= 6 and win is False:
print(f"=== Turn {tries}/{max_tries} ===")
player_input: str = input_guess(len(secret))
print(emojified(player_input, secret))
if player_input == secret:
print(f"You won in {tries}/{max_tries} turns!")
win = True
tries += 1
if tries > 6:
print(f"X/{max_tries} - sorry, try again tomorrow!")


if __name__ == "__main__":
main()
134 changes: 134 additions & 0 deletions exercises/ex04_turtle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
"""Sunset Over the Ocean. Now With Sharks!"""

__author__ = "730474722"

from random import randint
from turtle import Turtle, colormode, done
colormode(255)


def main() -> None:
"""The entrypoint of my scene."""
square(0.0, 0.0, "#7B98EB")
square(-355.0, 0.0, "#7B98EB")
square(-355.0, -355.0, "#2660FF")
square(0.0, -355.0, "#2660FF")
semi_circle(160.0, 0.0)
scribble_waves(-170.0, 0.0)
i: int = 0
while i < 100:
stars(randint(-350, 350), randint(120, 350), randint(1, 10))
i += 1
sharks(300.0, -100.0, 35)
sharks(310.0, -160.0, 30)
sharks(260.0, -130.0, 40)
done()
return


def scribble_waves(x: float, y: float) -> None:
"""A reflection of the sunset."""
wavy: Turtle = Turtle()
wavy.speed(30)
wavy.color(247, 244, 131)
j: int = 0
wavy.penup()
wavy.goto(x, y)
wavy.pendown()
up = 320
zigzag: int = 178
while j < 13:
wavy.forward(up)
wavy.right(zigzag)
up *= .9
wavy.forward(up)
wavy.left(zigzag)
up *= .9
j += 1
wavy.hideturtle()
return


def square(x: float, y: float, color: str) -> None:
"""Draws a square given the coordinates and color."""
block: Turtle = Turtle()
block.speed(30)
block.goto(x, y)
block.color(f"{color}")
block.begin_fill()
i: int = 0
side: int = 355
while i < 4:
block.forward(side)
block.left(90)
i += 1
block.end_fill()
block.hideturtle()
return


def semi_circle(x: float, y: float) -> None:
"""Draws a semi-circle to the left starting from x, y."""
semi: Turtle = Turtle()
semi.speed(10)
semi.goto(x, y)
semi.pencolor("black")
semi.fillcolor("yellow")
semi.setheading(136)
semi.pendown()
semi.begin_fill()
i: int = 5
up: int = 40
while i < 15:
semi.left(i)
semi.forward(up)
i += 1
semi.goto(x, y)
semi.end_fill()
semi.hideturtle()
return


def stars(x: float, y: float, size: int) -> None:
"""Stars for the night sky."""
star: Turtle = Turtle()
star.speed(200)
star.pencolor("#FBFF75")
star.fillcolor("#D5D5D5")
j: int = 0
star.penup()
star.goto(x, y)
star.right(90)
star.pendown()
star.begin_fill()
while j < 4:
star.forward(size)
star.right(135)
star.forward(size)
star.left(45)
j += 1
star.end_fill()
star.hideturtle()
return


def sharks(x: float, y: float, size: int) -> None:
"""Draws 'sharks' to liven up the water."""
jaws: Turtle = Turtle()
jaws.penup()
jaws.goto(x, y)
jaws.pendown()
jaws.pencolor("black")
jaws.fillcolor("silver")
jaws.begin_fill()
jaws.forward(size)
jaws.left(130)
jaws.forward(size)
jaws.goto(x, y)
jaws.end_fill()
jaws.hideturtle()
return


if __name__ == "__main__":
main()
33 changes: 33 additions & 0 deletions exercises/ex05/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""List Utility Functions."""
__author__ = "730474722"


def only_evens(numbers: list[int]) -> list[int]:
"""Returns the even numbers in a list of integers."""
new_list: list[int] = list()
i: int = 0
while i < len(numbers):
if ((numbers[i] / 2) - (numbers[i] // 2)) > 0:
i += 1
else:
new_list.append(numbers[i])
i += 1
return new_list


def sub(a_list: list[int], x: int, y: int) -> list[int]:
"""A list which is a subset of the given list, between the specified start index and the end index -1.212"""
new_list: list[int] = list()
for values in a_list[x: y]:
new_list.append(values)
return new_list


def concat(list_one: list[int], list_two: list[int]) -> list[int]:
"""Returns a list containing all elements of the first list, followed by all elements of the second list."""
new_list: list[int] = list_one
i: int = 0
while i < len(list_two):
new_list.append(list_two[i])
i += 1
return new_list
Loading