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
rewona [7]
3 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]3 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 addition to librarians, what other type of worker would you expect to find employed in a school or library
diamong [38]
In a school or library you can find a managor or boss

3 0
4 years ago
Read 2 more answers
David writes an essay as part of an assignment at school. He wants to indent the first lines of several paragraphs. With a word
Fudgin [204]
The answer is self explanatory, B
5 0
3 years ago
Read 2 more answers
Tamera was responding to a complaint that one of the employees is having problems with the wired network connection on their lap
WARRIOR [948]

Answer:

tamera like from sister sister hehe

Explanation:

sorry i dont know the awnser

3 0
3 years ago
1. Implement the function dict_intersect, which takes two dictionaries as parameters d1 and d2, and returns a new dictionary whi
stich3 [128]

Answer:

1  

def dict_intersect(d1,d2): #create dictionary

  d3={} #dictionaries

  for key1,value1 in d1.items():       #iterate through the loop  

      if key1 in d2:   #checking condition

          d3[key1]=(d1[key1],d2[key1])   #add the items into the dictionary  

  return d 3

print(dict_intersect({'a': 'apple', 'b': 'banana'}, {'b': 'bee', 'c': 'cat'})) #display

2

def consolidate(*l1):  #create consolidate

  d3={} # create dictionary

  for k in l1:       #iterate through the loop

      for number in k:   #iterate through  the loop                               d3[number]=d3.get(number,0)+1   #increment the value

             return d 3 #return

print(consolidate([1,2,3], [1,1,1], [2,4], [1])) #display

Explanation:

1

Following are  the description of program

  • Create a dictionary i.e"dict_intersect(d1,d2) "   in this dictionary created a dictionary d3 .
  • After that iterated the loop and check the condition .
  • If the condition is true then add the items into the dictionary and return the dictionary d3 .
  • Finally print them that are specified in the given question .

2

Following are  the description of program

  • Create a dictionary  consolidate inside that created a dictionary "d3" .
  • After that iterated the loop outer as well as inner loop and increment the value of items .
  • Return the d3 dictionary and print the dictionary as specified in the given question .

5 0
4 years ago
The space where text and content is entered and positioned for onscreen reading or printing
tino4ka555 [31]

Answer:

Page.

Explanation:

A page typically occupies the largest portion of a document layout as it houses the main writeup or content of the document. The text contained in a document is written on a the main page of the document. The main page is surrounded by the page margin, which is an area which separates the tips or edges of an entire papwr and the writing area (page) of the document. The insertion point refers to an indicator which shows the position which a typed character will fall or be placed. Content written on a document's page is what is printed when the document is to be printed out and test entered on the page are what is seen by the reader.

4 0
3 years ago
Other questions:
  • How can I get a refund of my money back
    12·2 answers
  • The code below uses the Space macro which simply displays the number of blank spaces specified by its argument. What is the firs
    9·1 answer
  • The ________ occurs when the user presses the enter key without typing a value for an input operation.
    5·1 answer
  • A kerberos __________ is a set of managed nodes that share the same kerberos database.
    10·1 answer
  • A user on a home network needs to boost the signal of the wireless router. What should the user purchase to accomplish this?
    14·1 answer
  • this device can be used to type documents,send email,browse the internet,handle spreadsheets,do presentations,play games,and mor
    14·1 answer
  • Please help!
    15·1 answer
  • An anagram of a string is another string with the same characters in the same frequency, in any order. For example 'ab', 'bca, a
    5·1 answer
  • How i simplify this boolean expression ?A'.B'.C'+A'.B'.C+A'.B.C+A.B'.C+A.B.C
    6·2 answers
  • 7. Suppose that a RISC machine uses 5 register windows. a. How deep can the procedure calls go before registers must be saved in
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!