Write a Python program that reads lines from an input file called data.txt. Each line consists of a keyword, followed by a sequence of numbers separated by commas. The keyword UP indicates that the number should be sorted in ascending order, while the keyword DOWN indicates that the number should be sorted in descending order. The program sorts the numbers and saves them in the file called sorted.txt. For example, if the data.txt file contains
UP 25 35, 30, 40, 30
DOWN 20, 30, 25, 25 DOWN 35, 45, 40, 15, 16, 18
The file sorted.txt will contain
25 30 30 35 40
30 25 25 20
45 40 35 18 16 15
1
Expert's answer
2020-05-06T20:16:03-0400
Dear Mohammed, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment