# file name: w07_markus.py # # Complete the following steps: #  (1) Complete the following function according to its docstring. #  (2) Save your file after you make changes, and then run the file by #      clicking on the green Run button in Wing101. This will let you call your #      modified function in the Python shell. An asterisk * on the Wing101 #      w07_markus.py tab indicates that modifications have NOT been saved. #  (3) Test your function in the Wing101 shell by evaluating the examples from #      the docstring and confirming that the correct result is displayed. #  (4) Test your function using different function arguments. #  (5) When you are convinced that your function is correct, submit your #      modified file to MarkUs. You can find instructions on submitting a file #      to MarkUs in Week *2* Perform -> Accessing Part 2 of the #      Week 2 Perform (For Credit) on PCRS. #  (6) Verify you have submitted the right file to MarkUs by downloading it #      and checking that the downloaded file is the one you meant to submit. #  (7) We have also provided a checker test for you to run on MarkUs. Click on #      the Automated Testing tab and then Run tests to make sure your code #      passes our simple test case. Go back to step (1) if errors were reported #      and modify your work.  You may need to click on some arrows to see all #      of the error report. Note that we will run additional tests when we mark #      your submission. # #      NOTE: To test this function, you will need to have your test .txt files #      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. # #      You can use the sample_numbers.txt file to test your code, and you should #      also test with some other files to convince yourself your code is working #      correctly. # #      Tip: some programs like Notepad may show the .txt file all on one line. #      You can try opening your .txt files in Wing101 instead. # #      You do not need to submit your .txt files. from typing import TextIO def count_odds_from_file(number_file: TextIO) -> list[int]:     """Return a list of counts of odd numbers in each section of the file     number_file. Each section in number_file begins with a line that contains     only START and ends with a line that contains only END.     Preconditions: each line in number_file is either START, END, or a string     of digits that can be converted to an int.     number_file is properly formatted to contain 0 or more sections structured:     START     <0 or more lines of numbers>     END     >>> f = open('sample_numbers.txt')     >>> count_odds_from_file(f)     [1, 0, 2]     >>> f.close()     """

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

# file name: w07_markus.py
#
# Complete the following steps:
#  (1) Complete the following function according to its docstring.
#  (2) Save your file after you make changes, and then run the file by
#      clicking on the green Run button in Wing101. This will let you call your
#      modified function in the Python shell. An asterisk * on the Wing101
#      w07_markus.py tab indicates that modifications have NOT been saved.
#  (3) Test your function in the Wing101 shell by evaluating the examples from
#      the docstring and confirming that the correct result is displayed.
#  (4) Test your function using different function arguments.
#  (5) When you are convinced that your function is correct, submit your
#      modified file to MarkUs. You can find instructions on submitting a file
#      to MarkUs in Week *2* Perform -> Accessing Part 2 of the
#      Week 2 Perform (For Credit) on PCRS.
#  (6) Verify you have submitted the right file to MarkUs by downloading it
#      and checking that the downloaded file is the one you meant to submit.
#  (7) We have also provided a checker test for you to run on MarkUs. Click on
#      the Automated Testing tab and then Run tests to make sure your code
#      passes our simple test case. Go back to step (1) if errors were reported
#      and modify your work.  You may need to click on some arrows to see all
#      of the error report. Note that we will run additional tests when we mark
#      your submission.
#
#      NOTE: To test this function, you will need to have your test .txt files
#      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.
#
#      You can use the sample_numbers.txt file to test your code, and you should
#      also test with some other files to convince yourself your code is working
#      correctly.
#
#      Tip: some programs like Notepad may show the .txt file all on one line.
#      You can try opening your .txt files in Wing101 instead.
#
#      You do not need to submit your .txt files.

from typing import TextIO


def count_odds_from_file(number_file: TextIO) -> list[int]:
    """Return a list of counts of odd numbers in each section of the file
    number_file. Each section in number_file begins with a line that contains
    only START and ends with a line that contains only END.

    Preconditions: each line in number_file is either START, END, or a string
    of digits that can be converted to an int.
    number_file is properly formatted to contain 0 or more sections structured:
    START
    <0 or more lines of numbers>
    END

    >>> f = open('sample_numbers.txt')
    >>> count_odds_from_file(f)
    [1, 0, 2]
    >>> f.close()
    """

START
1
2
END
START
4
END
START
5
6
7
END
sample_numbers.txt-
Transcribed Image Text:START 1 2 END START 4 END START 5 6 7 END sample_numbers.txt-
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The question is ask odd number,why the answer is even number

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education