Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ada C22 Sphinx Class- Salma Anany #41

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

SalmaAnany
Copy link

No description provided.

Copy link

@yangashley yangashley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on Adagrams!

Let me know if you have questions about my comments!

Comment on lines +3 to +4
.idea
*.iml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When files are already being tracked by git, even after you add them to .gitignore they will continue to be tracked.

Be sure to review what files you have staged for commit before you add them so that you don't add files that shouldn't be tracked to the commit history.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out this resource to review how to untrack files that you do not want added to a commit/pull request.

@@ -1,11 +1,99 @@
import random

letter_counts = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the values in this variable do not change, we should name the variable with all capital letters to indicate to other developers that this is a constant. So letter_counts should be LETTER_COUNTS.

Read more about constant variables here.

def draw_letters():
pass
all_letters = []
hand= []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing whitespace before the equal sign. It should look like hand = []

It's a small thing, but as you write more code (and eventually contribute to a large codebase) it's important to be consistent with whitespaces so that the whole project stays neat. Here's the official Python style guide that covers whitespaces.

pass
all_letters = []
hand= []
for key in letter_counts:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer a more descriptive name than key for this variable. What does the key of the letter_counts dictionary represent?

How about naming it letter so it's like

for letter in letter_counts:
    # rest of your code

pass

score_list= []
for char in word.upper():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice job calling upper on word in the for-loop

Comment on lines +77 to +83
if char in score_chart.keys():
score_list.append(score_chart[char])
total_score = sum(score_list)
if len(word) >= 7:
total_score = total_score + 8

return total_score

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need score_list to sum the scores to find total_score? We can remove this extra data structure and reduce complexity by directly getting the score.

Something like:

   total_score = 0

    for letter in word.upper():
        total_score += SCORE_CHART[letter]
    if len(word) >= 7:
        total_score += 8
    return total_score

Comment on lines +80 to +81
if len(word) >= 7:
total_score = total_score + 8
Copy link

@yangashley yangashley Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer the literal integers 7 and 8 to be referenced by variables to make your code more self-documenting:

BONUS_LENGTH = 7
BONUS_POINTS = 8

if len(word) >= BONUS_LENGTH:
        total_score += BONUS_POINTS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While a hand can't be more than 10 letters and therefore a word can't be more than 10 letters, you could make this check more explicit and conform to the instructions in the README more by having the check on line 80 be: if 7 <= len(word) <= 10:

winning_score = score
winning_word = word
return winning_word, winning_score

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice job directly returning a tuple on line 99.

Comment on lines +96 to +98
winning_score = score
winning_word = word

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer lines 96-98 to come before lines 93-95 because the second check is assigning some value to winning_score and winning_word after they are initialized.

if winning_score < score:
    winning_score = score
    winning_word = word
elif winning_score == score and len(winning_word) != 10:
    if len(word) == 10 or len(winning_word) > len(word):
        winning_word = word

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants