![travisvb](/avatars/28809.jpg)
travisvb
30.06.2019 •
Computers and Technology
Which of the following stereotypes was used as a justification for slavery? the mammy the coon the sambo all of the above
Solved
Show answers
More tips
- H Horoscopes, Magic, Divination How to Cast a Love Spell on a Guy? Guide for Guys...
- F Family and Home How to Sew Curtain Tapes: Best Tips from Professionals...
- S Style and Beauty How are artificial nails removed?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- F Food and Cooking The Disease That Haunted Abraham Lincoln...
- C Computers and Internet How to Get Rid of Windows Genuine Check?...
- H Health and Medicine How to perform artificial respiration?...
- S Style and Beauty Tricks and Tips: How to Get Rid of Freckles...
- C Computers and Internet How Do You Refill Cartridges?...
- A Auto and Moto Battle for the Relocation of The Cherkizovsky Market: Who Won?...
Answers on questions: Computers and Technology
- C Computers and Technology Create a user.html file with a user form as follows: user name: submit when a user enters a value for the user name text box and clicks the submit button, the value is sent to...
- C Computers and Technology Which use case can be accomplished using a custom link? choose 3 ans a. navigate to a process to update the current record. b. navigate to a custom visual flow to update the...
- C Computers and Technology Alen is a network administrator in XYZ Inc. He has been assigned a task of configuring WSUS server. When he is in WSUS snap-in and configuring options, what does computer option...
- C Computers and Technology If a computer is capable only of manipulating and storing integers, what di themselves? how are these difficulties overcome...
- C Computers and Technology What is the definition of recursive as used in algorithms? what are the main two parts of a recursive algorithm? what are the overheads associated with recursive algorithms?...
- M Mathematics Jean spent $16 on new T shirts. If each shirt cost the same whole who’s dollar amount how many could she bought...
- H History The classical era saw the rise of many great empires, including the Han dynasty of China, the Gupta Empire of India, and the Aztec, Inca, and Maya Empires of the Americas. Fill...
- E English Which of these is an accurate and appropriate summary of paragraph 4 ?...
- H History 4. The Aztecs built their empire through trade and -...
- A Arts What is the definition of Otorhinolaryngologist? Pls answer!!! ignore the question what do u think abt this girl be honest.....?...
Ответ:
C the Sambo
Ответ:
see explaination
Explanation:
Python version : 2.7
Python program to read an input file with specified number of records to read
and output the top 3 ranked actors
The format of input file:
<number of records to read>
<actor_name>,<movie_name>
<actor_name>,<movie_name>
....
'''
#define the file name
filename = 'actors_movies.txt'
# create an empty dictionary to contain the actor name as key and number of movies they have acted as value
actors_movie_count = {}
# open the flie
fp = open(filename)
line = fp.readline() # read the first line
count = int(line)
i = 0
# loop to read count number of lines from file
while i < count:
line = fp.readline() # read a line
data = line.split(",") # split the input data into list of strings using comma as the delimiter
# check if actor name is present in the dictionary, then add 1 to its value
# strip is used to remove any leading or trailing space
if data[0].strip() in actors_movie_count:
actors_movie_count[data[0].strip()] += 1
else: # else insert a new record with actor name as its key and 1 as value
actors_movie_count[data[0].strip()] = 1
i += 1
# close the file
fp.close()
# get the list of names of actors and list of number of movies they have acted
actors = actors_movie_count.keys()
num_movies = actors_movie_count.values()
# loop to sort the actors list and num_movies list in descending order of count of movies
for i in range(len(num_movies)-1):
max = i
for j in range(i+1,len(num_movies)):
if num_movies[j] > num_movies[max]:
max = j
if max != i:
actors[max], actors[i] = actors[i], actors[max]
num_movies[max], num_movies[i] = num_movies[i], num_movies[max]
# rank the actors to add top 3 ranked actors to rank_actors list
rank = 1
rank_actors = []
# add the first actor to list
rank_actors.append(actors[0])
# loop from second to end of actors list
for i in range(1,len(actors)):
# if this actor has same number of movies as the actor before him, then assign same rank
if num_movies[i] == num_movies[i-1]:
# if rank <= 3, add the actor in rank_actors list
if rank <= 3:
rank_actors.append(actors[i])
else: # rank > 3, exit the loop
break
else: # assign 1 more rank that the previous
rank += 1
# if rank <= 3, add the actor in rank_actors list
if rank <= 3:
rank_actors.append(actors[i])
else: # rank > 3, exit the loop
break
# loop to display the top 3 ranked actors
for actor in rank_actors:
print(actor)
#end of program
see attachment for the program screenshot and output