... ... >>> expected_1 == actual_1 True >>> call_2 = # TODO: Fill in the ... ... >>> actual_2 = count_odd(call_2) >>> expected_2 = ... # TODO: Fill in the %3D >>> expected_2 == actual_2 True # TODO: Fill in the couht_odd(call_3) >>> call_3 = >>> actual_3 = >>> expected_3 = # TODO: Fill in the ... ... exnected 3 -- actual 3
... ... >>> expected_1 == actual_1 True >>> call_2 = # TODO: Fill in the ... ... >>> actual_2 = count_odd(call_2) >>> expected_2 = ... # TODO: Fill in the %3D >>> expected_2 == actual_2 True # TODO: Fill in the couht_odd(call_3) >>> call_3 = >>> actual_3 = >>> expected_3 = # TODO: Fill in the ... ... exnected 3 -- actual 3
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...
Related questions
Question
![22 expeCteu_l -
'LIILIICב LL . סעU יזד
..
40
>>> expected_1 == actual_1
41
True
42
>>> call_2 =
# TODO: Fill in the ...
...
43
>>> actual_2 = count_odd(call_2)
44
>>> expected_2 =
# TODO: Fill in the ...
45
>>> expected_2 == actual_2
46
True
47
>>> call_3
# TODO: Fill in the ...
%D
...
48
>>> actual_3 =
couht_odd(call_3)
49
>>> expected_3
# TODO: Fill in the ...
%3D
..
50
>>> expected_3
actual_3
51
True
52
>>> # TODO: Fill in the expected value below. (Task 2)
53
>>> actual =
count_odd([1, [2, 6, 5], [9, [8, 7]]])
54
>>> expected =
# TODO: Fill in the ..,
...
55
>>> actual ==
expected
56
True
57
58
# TODO: There is a bug in this implementation. Find and fix it. (Task 3)
59
if isinstance(obj, int):
60
if obj % 2 == 0:
61
return 0
62
else:
63
return 1
64
else:
65
for sublist in obj:
66
return count_odd(sublist)
67
68
69
gif __name_
' -_main__':](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5e07a53d-2e03-4174-b79b-d1f9181cccd9%2Fcbe97b01-5db8-4ae4-8592-60a1b693fe96%2Fsmf7h1_processed.png&w=3840&q=75)
Transcribed Image Text:22 expeCteu_l -
'LIILIICב LL . סעU יזד
..
40
>>> expected_1 == actual_1
41
True
42
>>> call_2 =
# TODO: Fill in the ...
...
43
>>> actual_2 = count_odd(call_2)
44
>>> expected_2 =
# TODO: Fill in the ...
45
>>> expected_2 == actual_2
46
True
47
>>> call_3
# TODO: Fill in the ...
%D
...
48
>>> actual_3 =
couht_odd(call_3)
49
>>> expected_3
# TODO: Fill in the ...
%3D
..
50
>>> expected_3
actual_3
51
True
52
>>> # TODO: Fill in the expected value below. (Task 2)
53
>>> actual =
count_odd([1, [2, 6, 5], [9, [8, 7]]])
54
>>> expected =
# TODO: Fill in the ..,
...
55
>>> actual ==
expected
56
True
57
58
# TODO: There is a bug in this implementation. Find and fix it. (Task 3)
59
if isinstance(obj, int):
60
if obj % 2 == 0:
61
return 0
62
else:
63
return 1
64
else:
65
for sublist in obj:
66
return count_odd(sublist)
67
68
69
gif __name_
' -_main__':
![from typing import Union, List
def count_odd(obj: Union[int, List]) -> int:
" I" "Return the number of odd numbers in <obj>.
TODO: Task 1
Consider the call count_odd([1, [2, 6, 5], [9, [8, 7]]])
In the doctest below, fill in the "..." with the three recursive
calls that are made in count_odd([1, [2, 6, 5], [9, [8, 7]]])
and what each call *should* return.
e.g. if the first recursive call was made to the value 15, then
you would replace the ... to have
call_1 = 15
>>> call_1 =
# TODO: Fill in the ...
...
>>> actual_1 =
count_odd(call_1)
>>> expected_1 =
# TODO: Fill in the
>>> expected_1
actual_1
True
>>> call_2 = ...
# TODO: Fil in the ...
>>> actual_2 = count_odd(call_2)
%3D
>>> expected_2 =
# TODO: Fill in the
= .. .
>>> expected_2
== actual_2
True
>>> call_3 =
# TODO: Fill in the ...
...
>>> actual_3 = count_odd(call_3)
>>> expected_3 :
# TODO: Fill in the
...
>>> expected_3
actual_3
==
True.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5e07a53d-2e03-4174-b79b-d1f9181cccd9%2Fcbe97b01-5db8-4ae4-8592-60a1b693fe96%2Fd9br1y_processed.png&w=3840&q=75)
Transcribed Image Text:from typing import Union, List
def count_odd(obj: Union[int, List]) -> int:
" I" "Return the number of odd numbers in <obj>.
TODO: Task 1
Consider the call count_odd([1, [2, 6, 5], [9, [8, 7]]])
In the doctest below, fill in the "..." with the three recursive
calls that are made in count_odd([1, [2, 6, 5], [9, [8, 7]]])
and what each call *should* return.
e.g. if the first recursive call was made to the value 15, then
you would replace the ... to have
call_1 = 15
>>> call_1 =
# TODO: Fill in the ...
...
>>> actual_1 =
count_odd(call_1)
>>> expected_1 =
# TODO: Fill in the
>>> expected_1
actual_1
True
>>> call_2 = ...
# TODO: Fil in the ...
>>> actual_2 = count_odd(call_2)
%3D
>>> expected_2 =
# TODO: Fill in the
= .. .
>>> expected_2
== actual_2
True
>>> call_3 =
# TODO: Fill in the ...
...
>>> actual_3 = count_odd(call_3)
>>> expected_3 :
# TODO: Fill in the
...
>>> expected_3
actual_3
==
True.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY