THIS IS A PYTHON PROGRAM
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
Please indent the
code according to the screenshot given.
Do comment if you have any queries , thanks
Code
Screenshot:
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:
THIS IS A PYTHON PROGRAM student.txt Ann Bob Carla Dennis Eric Frank Greg Harry faculty.txt Fred...
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...