forked from AdaGold/viewing-party
-
Notifications
You must be signed in to change notification settings - Fork 167
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
Nancy - Lions #161
Open
nancy-lee89
wants to merge
9
commits into
Ada-C18:master
Choose a base branch
from
nancy-lee89:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Nancy - Lions #161
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5c99229
wave one completed
nancy-lee89 f16a4a9
passed first part of wave 2
nancy-lee89 43dc648
updated unique watched to use a list instead of set
nancy-lee89 fdbdc7d
finished wave 3
nancy-lee89 71404ad
passed all of the tests for wave 4
nancy-lee89 53c05ed
finished wave 5
nancy-lee89 118b456
working from scratch on wave 2 on my own
nancy-lee89 bd2146b
finished part 1 and half of part 2 from wave 2
nancy-lee89 0623e86
redid wave 2 with the help of tutor
nancy-lee89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -31,19 +31,57 @@ def watch_movie(user_data, title): | |
# ------------- WAVE 2 -------------------- | ||
# ----------------------------------------- | ||
|
||
# my own work with the help of tutor | ||
def get_watched_avg_rating(user_data): | ||
count = 0 | ||
average_rating = 0 | ||
|
||
for i in range(len(user_data["watched"])): | ||
count += (user_data["watched"][i]["rating"]) | ||
average_rating = count/len(user_data["watched"]) | ||
return average_rating | ||
|
||
def get_most_watched_genre(user_data): | ||
genre_fave = [] # ['Fantasy', 'Fantasy', 'Fantasy', 'Action', 'Intrigue', 'Intrigue'] | ||
count = 0 | ||
current_highest = "" | ||
|
||
for users_list in user_data["watched"]: | ||
genre_fave.append(users_list["genre"]) | ||
|
||
for element in genre_fave: | ||
if count < genre_fave.count(element): # count = 0 vs action=1 | ||
current_highest = element | ||
count = genre_fave.count(element) # =1 | ||
|
||
if len(user_data["watched"]) == 0: | ||
return None | ||
|
||
return current_highest | ||
Comment on lines
+44
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works great! A few notes:
|
||
# print(count, current_highest) | ||
# for i in range(len(user_data["watched"])): | ||
# popular_genre = [] | ||
# if popular_genre == []: | ||
# return None | ||
# elif i not in popular_genre: | ||
# popular_genre.append(i) | ||
|
||
# return popular_genre | ||
|
||
""" | ||
THIS IS THE WORK OF A GROUP | ||
def get_watched_avg_rating(user_data): | ||
sum = 0 | ||
average = 0 | ||
|
||
for i in range(len(user_data["watched"])): | ||
sum += (user_data["watched"][i]["rating"]) | ||
sum += (user_data["watched"][i]["rating"]) | ||
average = sum/len(user_data["watched"]) | ||
return average | ||
|
||
def get_most_watched_genre(user_data): | ||
index = 0 | ||
genres = [] | ||
least_popular = [] | ||
most_popular = [] | ||
if user_data == {"watched":[]}: | ||
return None | ||
|
@@ -52,11 +90,9 @@ def get_most_watched_genre(user_data): | |
index +=1 | ||
genres.append(user_data["watched"][index-1]["genre"]) | ||
for item in genres: | ||
if item not in least_popular: | ||
least_popular.append(item) | ||
else: | ||
most_popular.append(item) | ||
most_popular.append(item) | ||
return (most_popular[0]) | ||
""" | ||
|
||
# ----------------------------------------- | ||
# ------------- WAVE 3 -------------------- | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works great! You could also consider using a a for-each loop here:
for movie in user_data["watched"]
Then, we could just get
movie["rating"]
instead ofuser_data["watched"][i]["rating"]
, a lot easier to work with!