199k views
3 votes
Boardman College maintains two files—one for Sociology majors and another for Anthropology majors. Each file contains students' ID numbers, last names, first names, and grade point averages. Each file is in student ID number order. The college is merging the two departments into a Department of Sociology and Anthropology. Design the logic for a program that merges the two files into one file containing a list of all students, maintaining ID number order.

User Kasean
by
5.0k points

1 Answer

3 votes

Answer:

Step-by-step explanation:

#say the two files are converted to lists

Sociology major and Anthropology major

#Create new list

SociologyandAnthropology=[]

#loop through sociology list

for x in Sociology major:

a=[]

for y in Anthropology major:

for i in range (0,no.of items,1):

if x[i] == y[i]:

a.append(x[i])

else:

a.append(x[i])

a.append(y[i])

SociologyandAnthropology.append(a)

#sort using ID number

z=ID number index

SociologyandAnthropology=sorted(SociologyandAnthropology,key=lambda x:x[z]).

User Mike Hanson
by
3.9k points