Question 1
Write a program, question1.py, where the user can input student numbers of students in a class and the program writes this data to a file called “question1.out”. All student numbers are 9 characters long. The input will end with the word DONE. The question1.out file must have each student number on a new line, exactly as in the example below:
Example question1.out:
APPLES001
ORNGES002
BNNASH004
KWSBLE005
PRSSON003
Question 2
Write a program, question2.py, to read in the file “question1.out” saved above, and output a new file called “question2.out”. This new file should have the student numbers sorted in alphabetical order:
Examplequestion2.out:
APPLES001
BNNASH004
KWSBLE005
ORNGES002
PRSSON003
Problem.
Question 1
Write a program,question1.py, where the user can input student numbers of students in a class
and the program writes this data to a file called “question1.out”. All student
numbers are 9 characters long. The input will end with the word DONE. The
question1.out file must have each student number on a new line, exactly as in
the example below:
Example question1.out:
APPLES001
ORNGES002
BNNASH004
KWSBLE005
PRSSON003
Question 2
Write a program, question2.py, to read in thefile “question1.out” saved above, and output a new file called “question2.out”.
This new file should have the student numbers sorted in alphabetical order:
Examplequestion2.out:
APPLES001
BNNASH004
KWSBLE005
ORNGES002
PRSSON003
Code (Question 1).
fout = open('question1.out', 'w')
while True:
student_number = input()
if student_number == "DONE":
break
else:
fout.write(student_number + )
Code(Question 2).
fin = open('question1.out', 'r')
fout = open('question2.out', 'w')
list = []
for line in fin:
list.append(line.strip())
list.sort()
for student_number in list:
fout.write(student_number + "\n")
question1.out
APPLES001
ORNGES002
BNNASH004
KWSBLE005
PRSSON003
question2.out
APPLES001
BNNASH004
KWSBLE005
ORNGES002
PRSSON003