answer.
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
rewona [7]
2 years ago
11

Write a function addingAllTheWeirdStuff which adds the sum of all the odd numbers in array2 to each element under 10 in array1.

Similarly, addingAllTheWeirdStuff should also add the sum of all the even numbers in array2 to those elements over 10 in array1.
Computers and Technology
1 answer:
RSB [31]2 years ago
3 0

Answer:

The function is as follows:

def addingAllTheWeirdStuff(array1,array2):

   sumOdd = 0

   for i in array2:

       if i % 2 == 1:

           sumOdd+=i

   for i in array1:

       if i < 10:

           sumOdd+=i

   print("Sum:",sumOdd)

   

   sumEven = 0

   for i in array1:

       if i % 2 == 0:

           sumEven+=i

   for i in array2:

       if i > 10:

           sumEven+=i

   print("Sum:",sumEven)

Explanation:

This declares the function

def addingAllTheWeirdStuff(array1,array2):

This initializes the sum of odd numbers in array 2 to 0

   sumOdd = 0

This iterates through array 2

   for i in array2:

This adds up all odd numbers in it

<em>        if i % 2 == 1:</em>

<em>            sumOdd+=i</em>

This iterates through array 1

   for i in array1:

This adds up all elements less than 10 to sumOdd

<em>        if i < 10:</em>

<em>            sumOdd+=i</em>

This prints the calculated sum

   print("Sum:",sumOdd)

   

This initializes the sum of even numbers in array 1 to 0

   sumEven = 0

This iterates through array 1

   for i in array1:

This adds up all even numbers in it

<em>        if i % 2 == 0:</em>

<em>            sumEven+=i</em>

This iterates through array 2

   for i in array2:

This adds up all elements greater than 10 to sumEven

<em>        if i > 10:</em>

<em>            sumEven+=i</em>

This prints the calculated sum

   print("Sum:",sumEven)

You might be interested in
In step 4 of the CSMA/CA protocol, a station that successfully transmits a frame begins the CSMA/CA protocol for a second frame
DerKrebs [107]

Answer:

There could be a collision if a hidden node problem occurs.

Explanation:

CSMA/CA(carrier sense multiple access/ collision avoidance) is a multiple access method in wireless networking, that allows multiple node to transmit. Collision avoidance of this method is based on preventing signal loss or downtime as a result of collision of transmitting multi signals.

If a node at step 4(transmit frame) sends the first frame, the node still needs to send a RTS(request to send) and to receive a Clear to send (CTS) from the WAP, the is to mitigate the issue of hidden node problem as all frame are treated as unit, so other listening nodes, not detected would seek to connect and transmit as well.

5 0
2 years ago
A 'array palindrome' is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are sa
muminat

The code below is used to determine a recursive, bool-valued function, isPalindrome, that accepts an integer-valued array, and the number of elements and returns whether the array is a palindrome.

Explanation:

  • The code shows 'array palindrome' is an array which, when its elements are reversed, remains the same.

bool isPalindrome(arr[((n-1) - n) +1], n)

{

   if (n == 0 || n == 1)

   {

       return true;

   }

   else if (arr[n-1] == isPalindrome(arr[], n-1)

   {

       return true;

   }  

   else {

       return false;

   }

}

5 0
2 years ago
Steps in creating a folder
enyata [817]
Right click computer screen and press new folder?
or add paper to rings in the physical folder<span />
8 0
2 years ago
a.Write a Python function sum_1k(M) that returns the sum푠푠= ∑1푘푘푀푀푘푘=1b.Compute s for M = 3 by hand and write
stealth61 [152]

Answer:

def sum_1k(M):

   s = 0

   for k in range(1, M+1):

       s = s + 1.0/k

   return s

def test_sum_1k():

   expected_value = 1.0+1.0/2+1.0/3

   computed_value = sum_1k(3)

   if expected_value == computed_value:

       print("Test is successful")

   else:

       print("Test is NOT successful")

test_sum_1k()

Explanation:

It seems the hidden part is a summation (sigma) notation that goes from 1 to M with 1/k.

- Inside the <em>sum_1k(M)</em>, iterate from 1 to M and calculate-return the sum of the expression.

- Inside the <em>test_sum_1k(),</em> calculate the <em>expected_value,</em> refers to the value that is calculated by hand and <em>computed_value,</em> refers to the value that is the result of the <em>sum_1k(3). </em>Then, compare the values and print the appropriate message

- Call the <em>test_sum_1k()</em> to see the result

8 0
2 years ago
The Internet is BEST described as a vast _______ connection of computer networks that also link to smaller networks
storchak [24]
Whats ur choices if there web or world try them

4 0
2 years ago
Other questions:
  • Which statement best describes how the rapid prototyping model works?a) Developers create prototypes to show stakeholders how va
    11·2 answers
  • What is a typical grace period for a credit card...
    15·2 answers
  • 5.William travels a lot on business purpose. He needs to regularly communicate with his business partner. He also needs to send
    15·1 answer
  • Ismael would like to insert a question mark symbol in his document. What steps will he need to follow to do that?
    5·2 answers
  • To gain experience of using and combing different sorting algorithms: election sort, insertion sort, merge sort, and quick sort.
    14·1 answer
  • A data center that is fully automated to the extend that they can run and manage themselves while being monitored remotely are s
    11·1 answer
  • Given three dictionaries, associated with the variables, canadian_capitals, mexican_capitals, and us_capitals, that map province
    11·1 answer
  • Write a method called justFirstAndLast that takes a single String name and returns a new String that is only the first and last
    9·1 answer
  • Joe, Kate and Jody are members of the same family. Kate is 5 years older than Joe. Jody is 6 years older than Kate . The sum of
    11·2 answers
  • You know that you should check the room for security against unwanted entry do you check locks on doors and windows. What else d
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!