Answered step by step
Verified Expert Solution
Question
1 Approved Answer
add two lines to listsort.py so it uses .sort() then copy the listsort.py code into a file called mysort.py Modify my sort.py so that it
add two lines to listsort.py so it uses .sort()
In this repo, there is a Python program called listsort.py that has a given list: lyst = (1, 4, 2, 0, 3) and prints it. Extend (add two lines to) listsort.py so that it uses the native .sort() method included with Python's list class. Print-out the sorted list. Upload your modified program to this remote repo. (Be sure to update the DOCSTRING and include at least two single-line comments). To test your code, use: pytest or pytest test/test_listsort.py: IMPORTANT: Your code should really pass the first test. You need to write the second test (see below)... Now, copy listsort.py into the file: mysort.py. Modify mysort.py so that it starts from a different list and sorts it (make up your own list). Run your code to make sure that it works. Finally, copy test/test_listsort.py to the file: test/test_mysort.py Study your version VERY carefully. Modify your version so that it: calls your mysort.py (instead of the original listsort.py) tests for your original unsorted list and the sorted list (you should be able to modify the original) IMPORTANT: Be sure that your test program is named: test/test_mysort.py. Be sure to upload BOTH your modified program and its accompanying pytest program to this repo: IMPORTANT: Be sure that your test program is named: test/test_mysort.py. Be sure to upload BOTH your modified program and its accompanying pytest program to this repo: mysort.py test_mysort.py NOTE . Python uses timsort In regular expressions, re (in the assert statement of the pytest files): means almost any character except newline: * means 0 or more instances of the preceeding character o 0 listsort.py listsort.py You, a few seconds ago | 2 authors (github-classroom[bot] and others) 1 You, a few seconds ago Uncommitted changes 2 3 v if name__ == "_main__": 4 lyst = (1, 4, 2, 0, 3] 5 print(lyst) 6 test > test_listsort.py > ... You, a few seconds ago | 2 authors (github-classroom[bot] and others) 1 2 test of listsort.py 3 41 You, a few seconds ago . Uncommitted changes 5 6 7 import sys 8 import subprocess 9 import re III 10 11 12 13 14 15 16 17 18 19 def test_sort(): result = subprocess.run( (sys.executable, "./listsort.py") , stdout=subprocess.PIPE . stderr=subprocess.PIPE , encoding="utf-8" assert re.search("1, 4, 2, 6, 3.* .*0, 1, 2, 3, 4", result.stdout) 2 then copy the listsort.py code into a file called mysort.py
Modify my sort.py so that it starts with a different list you make.
then edit the test_listsort.py, and make it check the code of sort.py
Copy the test_listsort.py and make a test_mysort.py for mysort.py
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started