Commit 186bda75 authored by Adam Blank's avatar Adam Blank
Browse files

go

parent 364197df
Showing with 8 additions and 6 deletions
+8 -6
UPPERCASE_LETTERS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", UPPERCASE_LETTERS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
"L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
LOWERCASE_LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", LOWERCASE_LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
......
...@@ -2,11 +2,11 @@ from joke_types import Joke ...@@ -2,11 +2,11 @@ from joke_types import Joke
from joke_library import get_n_jokes, rate_joke, tell_joke from joke_library import get_n_jokes, rate_joke, tell_joke
def get_average_joke_rating(ratings: dict[int, int]): def get_average_joke_rating(ratings: dict[int, int]) -> float:
return ... ...
def find_best_joke(jokes: dict[int, Joke], joke_ratings: dict[int, int]): def find_best_joke(jokes: dict[int, Joke], joke_ratings: dict[int, int]) -> Joke | None:
best_joke_id: int = -1 best_joke_id: int = -1
... ...
...@@ -14,7 +14,7 @@ def find_best_joke(jokes: dict[int, Joke], joke_ratings: dict[int, int]): ...@@ -14,7 +14,7 @@ def find_best_joke(jokes: dict[int, Joke], joke_ratings: dict[int, int]):
return jokes_by_id[best_joke_id] return jokes_by_id[best_joke_id]
def tell_jokes(n: int = 3): def tell_jokes(n: int = 3) -> tuple[dict[int, Joke], dict[int, int]]:
jokes = get_n_jokes(n) jokes = get_n_jokes(n)
# Make a dictionary of jokes keyed by id # Make a dictionary of jokes keyed by id
...@@ -37,4 +37,6 @@ print() ...@@ -37,4 +37,6 @@ print()
print("The average rating you gave was..." + print("The average rating you gave was..." +
str(get_average_joke_rating(joke_ratings))) str(get_average_joke_rating(joke_ratings)))
print("The best joke was...") print("The best joke was...")
tell_joke(find_best_joke(jokes_by_id, joke_ratings)) best_joke = find_best_joke(jokes_by_id, joke_ratings)
assert best_joke is not None
tell_joke(best_joke)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment