Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

undefined 8 1 IIII Week 7 Perform - Part 2 2 3 Complete the following steps: 4 (1) Complete the following function according to its

image text in transcribedimage text in transcribedundefined

8 1 IIII "Week 7 Perform - Part 2 2 3 Complete the following steps: 4 (1) Complete the following function according to its docstring. 5 (2) Save your file after you make changes, and then run the file by 6 clicking on the green Run button in Wing101. This will let you call your 7 modified function in the shell. An asterisk * on the Wing101 w07_markus.py tab indicates that modifications have NOT been saved. 9 (3) Test your functions in the Wing101 shell by evaluating the examples from 10 the docstring and confirming that the correct result is displayed. 11 (4) Test your functions using different function arguments. 12 (5) When convinced that your functions are correct, submit your modified 13 file to Markus. You can find instructions on submitting a file to Markus 14 in the Week *2* Perform on PCRS. 15 (6) Verify you have submit the right file to Markus by downloading it again 16 and checking it is the one you meant to submit. 17 (7) We have also provided a checker test for you to run in Markus. Run this 18 to make sure your code passes a simple test case. Note that we will run 19 additional tests when we mark your submission. 20 21 NOTE: To test this function, you will need to have your test .txt files 22 in the same folder, and those .txt files will need to have the same format 23 as the sample_numbers.txt file that you can download from Markus. 24 25 You can use the sample_numbers.txt file to test your code, and you should 26 also test with some other files to convince yourself your code is working 27 correctly. 28 29 Tip: some programs like Notepad may show the .txt file all on one line. 30 You can try opening your .txt files in Wing101 instead. 31 32 You do not need to submit your .txt files. 33 2 START 1 2 END START 3 END START 4 5 6 END 8 14 16 19 20 wo7_markus.py) No Selection 1 Week 7 Perform - Part 2 - 2 3 Complete the following steps: 4 (1) Complete the following function according to its docstring. 5 (2) Save your file after you make changes, and then run the file by 6 clicking on the green Run button in Wing101. This will let you call your 7 modified function in the shell. An asterisk * on the Wing101 w07_markus.py tab indicates that modifications have NOT been saved. 9 (3) Test your functions in the Wing101 shell by evaluating the examples from 10 the docstring and confirming that the correct result is displayed. 11 11 (4) Test your functions using different function arguments. 12 (5) When convinced that your functions are correct, submit your modified 13 file to Markus. You can find instructions on submitting a file to Markus in the Week *2* Perform on PCRS. 15 (6) Verify you have submit the right file to Markus by downloading it again and checking it is the one you meant to submit. 17 (7) We have also provided a checker test for you to run in Markus. Run this 18 to make sure your code passes a simple test case. Note that we will run additional tests when we mark your submission. 20 21 NOTE: To test this function, you will need to have your test .txt files 22 in the same folder, and those .txt files will need to have the same format as the sample_numbers.txt file that you can download from Markus. 24 You can use the sample_numbers.txt file to test your code, and you should 26 also test with some other files to convince yourself your code is working 27 correctly. 28 29 Tip: some programs like Notepad may show the .txt file all on one line. 30 You can try opening your .txt files in Wing101 instead. 31 32 You do not need to submit your .txt files. 33 34 35 from typing import List, TextIO 36 37 def count_evens_from_file(number_file: TextIO) -> List[int]: 38 "Return a list of counts of even numbers in each section of the file 39 number_file. Each section in number_file begins with a line that contains only START and ends with a line that contains only END. 41 42 Preconditions: each line in number_file is either START, END, or a string 43 of digits that can be converted to an int. number_file is properly formatted to contain 0 or more sections structured: 45 >> f = open('sample_numbers.txt') >>> count_evens_from_file(f) (1, 0, 2] >>> f.close() 51 52 53 54 8 1 IIII "Week 7 Perform - Part 2 2 3 Complete the following steps: 4 (1) Complete the following function according to its docstring. 5 (2) Save your file after you make changes, and then run the file by 6 clicking on the green Run button in Wing101. This will let you call your 7 modified function in the shell. An asterisk * on the Wing101 w07_markus.py tab indicates that modifications have NOT been saved. 9 (3) Test your functions in the Wing101 shell by evaluating the examples from 10 the docstring and confirming that the correct result is displayed. 11 (4) Test your functions using different function arguments. 12 (5) When convinced that your functions are correct, submit your modified 13 file to Markus. You can find instructions on submitting a file to Markus 14 in the Week *2* Perform on PCRS. 15 (6) Verify you have submit the right file to Markus by downloading it again 16 and checking it is the one you meant to submit. 17 (7) We have also provided a checker test for you to run in Markus. Run this 18 to make sure your code passes a simple test case. Note that we will run 19 additional tests when we mark your submission. 20 21 NOTE: To test this function, you will need to have your test .txt files 22 in the same folder, and those .txt files will need to have the same format 23 as the sample_numbers.txt file that you can download from Markus. 24 25 You can use the sample_numbers.txt file to test your code, and you should 26 also test with some other files to convince yourself your code is working 27 correctly. 28 29 Tip: some programs like Notepad may show the .txt file all on one line. 30 You can try opening your .txt files in Wing101 instead. 31 32 You do not need to submit your .txt files. 33 2 START 1 2 END START 3 END START 4 5 6 END 8 14 16 19 20 wo7_markus.py) No Selection 1 Week 7 Perform - Part 2 - 2 3 Complete the following steps: 4 (1) Complete the following function according to its docstring. 5 (2) Save your file after you make changes, and then run the file by 6 clicking on the green Run button in Wing101. This will let you call your 7 modified function in the shell. An asterisk * on the Wing101 w07_markus.py tab indicates that modifications have NOT been saved. 9 (3) Test your functions in the Wing101 shell by evaluating the examples from 10 the docstring and confirming that the correct result is displayed. 11 11 (4) Test your functions using different function arguments. 12 (5) When convinced that your functions are correct, submit your modified 13 file to Markus. You can find instructions on submitting a file to Markus in the Week *2* Perform on PCRS. 15 (6) Verify you have submit the right file to Markus by downloading it again and checking it is the one you meant to submit. 17 (7) We have also provided a checker test for you to run in Markus. Run this 18 to make sure your code passes a simple test case. Note that we will run additional tests when we mark your submission. 20 21 NOTE: To test this function, you will need to have your test .txt files 22 in the same folder, and those .txt files will need to have the same format as the sample_numbers.txt file that you can download from Markus. 24 You can use the sample_numbers.txt file to test your code, and you should 26 also test with some other files to convince yourself your code is working 27 correctly. 28 29 Tip: some programs like Notepad may show the .txt file all on one line. 30 You can try opening your .txt files in Wing101 instead. 31 32 You do not need to submit your .txt files. 33 34 35 from typing import List, TextIO 36 37 def count_evens_from_file(number_file: TextIO) -> List[int]: 38 "Return a list of counts of even numbers in each section of the file 39 number_file. Each section in number_file begins with a line that contains only START and ends with a line that contains only END. 41 42 Preconditions: each line in number_file is either START, END, or a string 43 of digits that can be converted to an int. number_file is properly formatted to contain 0 or more sections structured: 45 >> f = open('sample_numbers.txt') >>> count_evens_from_file(f) (1, 0, 2] >>> f.close() 51 52 53 54

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started