1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nezavi [6.7K]
2 years ago
13

Problem 8 - Recursive Divisible by 3 and 5 Complete the divBy3And5 function which accepts a list of integers. The function shoul

d recursively determine how many numbers in the list are divisible by 3 and how many are divisible by 5 and return these counts as a two-element tuple. Your solution MUST BE RECURSIVE and you MAY NOT USE LOOPS. You MAY NOT DEFINE A RECURSIVE HELPER FUNCTION.
Computers and Technology
1 answer:
slavikrds [6]2 years ago
5 0

The recursive function divBy3And5 is defined in Python and is found in the attached image.

In the base case, the function divBy3And5 tests if the input list is empty. If so, the tuple returned is (0, 0). This means no numbers are divisible by three and no numbers are divisible by five.

The recursive step gets the first element of the list and

  • If divisible by 3, it sets <em>count_of_3</em> to 1, else it leaves it as 0
  • If divisible by 5, it sets <em>count_of_5</em> to 1, else it leaves it as 0

It then makes a recursive call on the remaining elements, and stores it in a variable as follows

   <em>divBy3And5_for_remaining_elem</em> = divBy3And5(remaining_elements)

Then, it returns the tuple

       (<em>divBy3And5_for_remaining_elem</em>[0] + <em>count_of_3</em>,

                <em>divBy3And5_for_remaining_elem</em>[1] + <em>count_of_5)</em>

Learn more about recursion in Python: brainly.com/question/19295093

You might be interested in
On many advanced routers and switches, you can implement QoS through bandwidth management, such as __________, where you control
Mila [183]

Answer:

c. traffic shaping

Explanation:

A traffic shaping system is one that allows to adapt the incoming data traffic that comes from some node of the network giving it a special treatment called conformation of accepted traffic and thus allowing the frames to be forwarded through the network of data under traffic rules without having gone through some traffic shaping method, this can be detected as non-conforming traffic at the edge of access to the discarded metropolitan network.

Traffic shaping is a mechanism that alters the traffic characteristics of the cell flow of a connection to achieve better network efficiency while maintaining QoS objectives or in order to ensure that the cell flow conforms to traffic parameters according to the leaky bucket algorithm configuration of the traffic contract. Traffic shaping can be used in ATM, for example, to reduce peak speed, limit the length of the burst by means of adequate spacing of cells over time. The use and location of this function is network specific.

5 0
3 years ago
!! HELP PLZ !!
DochEvi [55]
I think it might be short range and long-term
3 0
3 years ago
Read 2 more answers
When a user problem cannot be solved by the help desk at the first level of resolution, the problem is ___________ to the second
PIT_PIT [208]

Answer: escalated

Explanation:

7 0
3 years ago
Xét bài toán QUẢN LÝ ĐÀO TẠO. Việc quản lý đào tạo tại một trường đại học có thể được mô tả vắn tắt như sau: Danh sách Giảng viê
gulaghasi [49]

Answer:

write in an English so we can help with that

5 0
3 years ago
Timeliness is an important goal of any access control monitoring system.<br> A. True<br> B. False
Damm [24]
The answer for this question is true
7 0
4 years ago
Other questions:
  • A security system uses sensors at every door and window which will set off an alarm if any one of them is opened. There is also
    9·1 answer
  • How to change font size and style and add a table when creating a webpage?
    6·1 answer
  • A network administrator wants to increase the speed and fault tolerance of a connection between two network switches. To achieve
    9·2 answers
  • Jack is writing a paragraph for a school assignment. He proofreads his paper and notices that he used the word, "then" many time
    15·2 answers
  • What are the differences between the various EHRs?
    9·1 answer
  • What is one expectation of open-source software?
    15·1 answer
  • From a database point of view, the collection of data becomes meaningful only when it reflect
    8·1 answer
  • Data bars are a form of ________.
    8·2 answers
  • Assessment
    12·1 answer
  • The tags are always enclosed within a pair of<br>(a) curly<br>(b) square<br>(©) angular​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!