1.) Sort movies based on the rating of the movie (key: 'rating') from highest to lowest. This time, break ties with the value of 'no_of_votes' (if two movies have the same rating, the one with more votes should come first)
movies = [{ "name" : "Inception", "rating" : 9, "no_of_votes":
10000},
{ "name" : "Tamasha", "rating" : 8, "no_of_votes" : 1000 },
{ "name" : "Dark Knight Rises" , "rating" : 9, "no_of_votes": 10200
}]
2.) Define a function smallest that accepts a list of integer and returns the smallest integer in the list passed to it. Implement smallest using one line of code. This should be done with a lambda function.
For example, smallest([4221, 5464, 34345, 45458]) should be 4221
#1
#method to sort list of movies based on rating and votes
def Sort(ml):
for i in range(len(ml)):
s=False
for j in range(0,len(ml)-i-1):
if ml[j+1]['rating']>ml[j]['rating']:
ml[j],ml[j+1]=ml[j+1],ml[j]
s=True
elif ml[j+1]['rating']==ml[j]['rating']:
if ml[j+1]['no_of_votes']>ml[j]['no_of_votes']:
ml[j],ml[j+1]=ml[j+1],ml[j]
s=True
if s==False:
break
#2
def Min():
return lambda a : min(a)
smallest =Min()
#testing above methods
movies = [{ "name" : "Inception", "rating" : 9, "no_of_votes":
10000},
{ "name" : "Tamasha", "rating" : 8, "no_of_votes" : 1000 },
{ "name" : "Dark Knight Rises" , "rating" : 9, "no_of_votes": 10200
}]
Sort(movies)
print(movies)
a=smallest([4221, 5464, 34345, 45458])
print(a)
1.) Sort movies based on the rating of the movie (key: 'rating') from highest to lowest....
BACKGROUND Movie Review sites collect reviews and will often provide some sort of average review to sort movies by their quality. In this assignment, you will collect a list of movies and then a list of reviews for each movie. You will then take a simple average (total of reviews divided by number of reviews) for each movie and output a sorted list of movies with their average review. Here you are provided the shell of a program and asked...
Phase 1 Requirements Code submitted for Phase 1 will only have the following capability. Any additional coding will result in the loss of point. code will have the main function, including looping until the user enters input of 12 code will call the printMenu() function theprintMenu() function will have the capability to print the menu and receive input. AT THIS TIME do not worry about implementing the try/except code code will return the integer value (remember - the input() function...