Question

THIS IS A PYTHON PROGRAM

Suppose you have been provided four (4) input files that contain the names of persons who are affiliated with Clark Atlanta U

student.txt

Ann

Bob

Carla

Dennis

Eric

Frank

Greg

Harry

faculty.txt

Fred

Wilma

Betty

Barney

Slate

Gazoo

staff.txt

Karen

Bob

Carla

Joan

DeeDee

Michelle

alumni.txt

John

Jane

Wilma

Barney

Gazoo

DeeDee

Joan

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please indent the code according to the screenshot given.
Do comment if you have any queries , thanks

Code Screenshot:

1 2 3 ##open all the files give exact path of the file if there are not in the same folder studentFile open(student.txt, r

print(Names of the persons who are common in both student and Staff, student & staff) 40 ##common in faculty and alumni pri

Executable Code:

##open all the files give exact path of the file if there are not in the same folder
studentFile=open("student.txt",'r')
facultyFile=open("faculty.txt",'r')
staffFile=open("staff.txt",'r')
alumniFile=open("alumni.txt",'r')

##create a empty set
student=set()
faculty=set()
alumni=set()
staff=set()

##read data into the sets by using readline
##rstrip is used here to eliminate the \n in the each line
##add is used to add elemnts to list
for i in studentFile.readlines():
   student.add(i.rstrip())

for i in facultyFile.readlines():
   faculty.add(i.rstrip())

for i in staffFile.readlines():
   staff.add(i.rstrip())

for i in alumniFile.readlines():
   alumni.add(i.rstrip())
##displaying names in all the files
print("Names of student ",student)
print("Names of faculty ",faculty)
print("Names of staff ",staff)
print("Names of alumni ",alumni)

## display all names by applying union
print("All name ",student | faculty|staff|alumni)

##common in studets and staff

print("Names of the persons who are common in both student and Staff",student & staff)

##common in faculty and alumni

print("Names of the persons who are common in both student and Staff",faculty & alumni)

## people who are staff but not alumni

print("Persons who are staff but not alumni ",staff-alumni)

##people who are alumni but not staff
print("Persons who are staff but not alumni ",alumni-staff)

Sample Output:
Names of student 1, Bob, Greg, Eric, Dennis, Ann, Harry, Frank, Carla}, Names of faculty {, Wilma, Sla

Add a comment
Know the answer?
Add Answer to:
THIS IS A PYTHON PROGRAM student.txt Ann Bob Carla Dennis Eric Frank Greg Harry faculty.txt Fred...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT