
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
Python
Using recursion only
No loops, no list method
Using such type()function, len()function, indexing, slicing
The function must return true(boolean) if a list has positive numbers otherwise returns false
def hasPosNum(lst):
![>>> ans = hasPosNum([])
ans
False
>>> type(ans)
<class 'bool'>
>>> ans = hasPosNum([1, [[[[-1, -3,0]], 4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
ans
True
hasPosNum([-1.5, [[[[-1,-3,0]], 4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
>>> ans =
>>> ans
True
>>> ans = hasPosNum(['three', [[[[-1, -3,0]], -4], True], True, 'Amber', 'Erin', [[[[False, 17]]]]])
>>> ans
True
>>> ans = hasPosNum([[[-1.5]], [[[[-1, -3, 0]], -4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
>>> ans
False
>>> ans =
hasPosNum([[[(1,2, 3)]], [[[[-1, -3,0]], -4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
>>> ans
False](https://content.bartleby.com/qna-images/question/67061b77-5467-4182-94fd-55ec16076bb1/5e249553-6d34-40a0-ab83-1f075155a334/ek6yca6_thumbnail.png)
Transcribed Image Text:>>> ans = hasPosNum([])
ans
False
>>> type(ans)
<class 'bool'>
>>> ans = hasPosNum([1, [[[[-1, -3,0]], 4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
ans
True
hasPosNum([-1.5, [[[[-1,-3,0]], 4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
>>> ans =
>>> ans
True
>>> ans = hasPosNum(['three', [[[[-1, -3,0]], -4], True], True, 'Amber', 'Erin', [[[[False, 17]]]]])
>>> ans
True
>>> ans = hasPosNum([[[-1.5]], [[[[-1, -3, 0]], -4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
>>> ans
False
>>> ans =
hasPosNum([[[(1,2, 3)]], [[[[-1, -3,0]], -4], True], True, 'Amber', 'Erin', [[[[False, -17]]]]])
>>> ans
False
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images

Knowledge Booster
Similar questions
- IN PYTHON THANK YOUarrow_forwardObjective: Write syntactically correct while/for loops Given a list of numbers and a number n, return the sum of the first n elements in the list. Assume n is less than or equal to the length of the list. For example, given [1, 1, 1, 5] and n=3, the function should return 3. (i.e. 1+1+1) user_code.py 1 # starter code 2 def sum_to_n(numbers, n): 3 4 & in 5 # your code here (replace pass with your code) *arrow_forwardA sequential search of a sorted list can halt when the target is less than a given element in the list. Modify the program to stop when the target becomes less than the current value being compared. In a sorted list, this would indicate that the target is not in the list and searching the remaining values is unnecessary. ----------------------------------------------------------------------------------- """ File: search.py Project 11.1 """ def sequentialSearch(target, lyst): """Returns the position of the target item if found, or -1 otherwise. The lyst is assumed to be sorted in ascending order.""" position = 0 while position < len(lyst): if target == lyst[position]: return position position += 1 return -1 def main(): """Tests with three lists.""" print(sequentialSearch(3, [0, 1, 2, 3, 4])) print(sequentialSearch(3, [0, 1, 2])) # Should stop at second position. print(sequentialSearch(3, [0, 4, 5, 6])) if…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

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