Help me create the following function constraints in w04c_ans.py  the test case file provided in one of the image is named w04c_test_public.py copy and paste it in notepad ++ for it to look exactly the same.    w04c_test_public.py import io import textwrap import unittest from unittest.mock import patch # TODO: Replace w04c_ans with the name of your Python file. #       Make sure that this file and that file are in the same #       folder. from w04c_ans import print_frame, is_valid_num class TestIsValidNum(unittest.TestCase):     def test_pt01(self):         a_test = is_valid_num('2')         self.assertTrue(a_test)     def test_pt02(self):         a_test = is_valid_num('-5')         self.assertFalse(a_test)     def test_pt03(self):         a_test = is_valid_num('512abc32')         self.assertFalse(a_test) class TestPrintFrame(unittest.TestCase):     @patch('sys.stdout', new_callable=io.StringIO)     def test_pt01(self, mocked_print):         print_frame()         self.assertEqual(             mocked_print.getvalue(),             textwrap.dedent(                 """\                 ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐                 │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │                 │   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┴───┤                 │       │       │       │       │       │       │       │       │       │           │                 └───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────────┘                 """             )         ) if __name__ == '__main__':     unittest.main() w04c_ans.py def print_frame():     pass def is_valid_num():     return False def main():

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Help me create the following function constraints in w04c_ans.py 

the test case file provided in one of the image is named w04c_test_public.py copy and paste it in notepad ++ for it to look exactly the same. 

 

w04c_test_public.py

import io
import textwrap
import unittest
from unittest.mock import patch

# TODO: Replace w04c_ans with the name of your Python file.
#       Make sure that this file and that file are in the same
#       folder.
from w04c_ans import print_frame, is_valid_num

class TestIsValidNum(unittest.TestCase):
    def test_pt01(self):
        a_test = is_valid_num('2')
        self.assertTrue(a_test)

    def test_pt02(self):
        a_test = is_valid_num('-5')
        self.assertFalse(a_test)

    def test_pt03(self):
        a_test = is_valid_num('512abc32')
        self.assertFalse(a_test)

class TestPrintFrame(unittest.TestCase):
    @patch('sys.stdout', new_callable=io.StringIO)
    def test_pt01(self, mocked_print):
        print_frame()

        self.assertEqual(
            mocked_print.getvalue(),
            textwrap.dedent(
                """\
                ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
                │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │   │
                │   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┤   └───┴───┤
                │       │       │       │       │       │       │       │       │       │           │
                └───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────────┘
                """
            )
        )

if __name__ == '__main__':
    unittest.main()



w04c_ans.py

def print_frame():
    pass

def is_valid_num():
    return False

def main():
    while True:
        num_frames = input('Enter number of frames from 2 to 10 inclusive: ')
        
        if not is_valid_num(num_frames):
            print('Entered input is either not a number or is not between 2 and 10 inclusive. Please try again.')
            continue

        num_frames = int(num_frames)

        print_frame(num_frames)
        break

if __name__ == '__main__':
    main()




Functional Constraints
You are required to have the following function signatures, their arguments in order, and their
return values:
print_frame - prints a bowling score frame spanning a certain number of games
O Arguments
len_frames - number frames to print; default is 10
O Return value - None; should print five lines denoting an ASCII-generated bowling
scoreboard
is_valid_num - computes whether the number entered is within the constrained range
O Arguments
O
num_in-number to check
Return value - bool representing True if the number is between 2 and 10 inclusive
or False otherwise
H
Transcribed Image Text:Functional Constraints You are required to have the following function signatures, their arguments in order, and their return values: print_frame - prints a bowling score frame spanning a certain number of games O Arguments len_frames - number frames to print; default is 10 O Return value - None; should print five lines denoting an ASCII-generated bowling scoreboard is_valid_num - computes whether the number entered is within the constrained range O Arguments O num_in-number to check Return value - bool representing True if the number is between 2 and 10 inclusive or False otherwise H
w04c_test_public.pyXw04c_ans.py X
import io
import textwrap
3 import unittest
4
5
1
2
6
7
8
25
26
27
28
29
30
31
32
33
34
9
10
11
12
13
14
15
16
17
18
19
20 8 def test_pt03 (self):
21
22
23
24
35 36 37 38 39 40 41 42 43 44
from unittest.mock import patch.
-0
#TODO: Replace w04c_ans with the name of your Python file.
Make sure that this file and that file are in the same
folder.
class TestIsValidNum (unittest. TestCase) :
8 def test_pt01 (self):
#
#
from w04c_ans import print_frame, is_valid_num
8
8
CI
a test is valid num (¹2¹)
self.assertTrue (a_test)
def test_pt02 (self):
a test is valid num ('-5')
self.assertFalse (a_test)
a_test = is_valid_num (¹512abc32¹)
self.assert False (a_test)
class TestPrintFrame (unittest. TestCase):
@patch('sys.stdout', new_callable=io. StringIO)
def test_pt01 (self, mocked_print):
print_frame ()
self.assertEqual (
Bif name
mocked_print.getvalue (),
textwrap. dedent (
111111
11 11 11
== ' main T:
unittest.main()
Transcribed Image Text:w04c_test_public.pyXw04c_ans.py X import io import textwrap 3 import unittest 4 5 1 2 6 7 8 25 26 27 28 29 30 31 32 33 34 9 10 11 12 13 14 15 16 17 18 19 20 8 def test_pt03 (self): 21 22 23 24 35 36 37 38 39 40 41 42 43 44 from unittest.mock import patch. -0 #TODO: Replace w04c_ans with the name of your Python file. Make sure that this file and that file are in the same folder. class TestIsValidNum (unittest. TestCase) : 8 def test_pt01 (self): # # from w04c_ans import print_frame, is_valid_num 8 8 CI a test is valid num (¹2¹) self.assertTrue (a_test) def test_pt02 (self): a test is valid num ('-5') self.assertFalse (a_test) a_test = is_valid_num (¹512abc32¹) self.assert False (a_test) class TestPrintFrame (unittest. TestCase): @patch('sys.stdout', new_callable=io. StringIO) def test_pt01 (self, mocked_print): print_frame () self.assertEqual ( Bif name mocked_print.getvalue (), textwrap. dedent ( 111111 11 11 11 == ' main T: unittest.main()
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY