Write a Python program that reads each line of an input file called data.txt that consists of a keyword followed by a sequence of numbers separated by commas. If the keyword is UP, the numbers are...


Write a Python program that reads each line of an input file called data.txt that consists of a keyword<br>followed by a sequence of numbers separated by commas. If the keyword is UP, the numbers are sorted<br>in increasing order, if the key word is DOWN; the numbers are sorted in decreasing order. The sorted<br>sequence of numbers is saved in sorted.txt. For example, if the data.txt contains<br>UP 25 35 30 40 30<br>DOWN 20 30 25 25<br>DOWN 35 45 40 15 16 18<br>The file sorted.txt will contain<br>25 30 30 35 40<br>30 25 25 20<br>45 40 35 18 16 15<br>

Extracted text: Write a Python program that reads each line of an input file called data.txt that consists of a keyword followed by a sequence of numbers separated by commas. If the keyword is UP, the numbers are sorted in increasing order, if the key word is DOWN; the numbers are sorted in decreasing order. The sorted sequence of numbers is saved in sorted.txt. For example, if the data.txt 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

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here