Given two lists of integers, write a function multLists(list1, list2) that multiplies each value of the list1 by the values of list2 and returns list1 with it's updated values. The lists will be obtained for you, just write the function and print the result.

Answers

Answer 1
Answer:

Answer:

FIRST SOLUTION

def multLists(list1,list2):

   for i in range(len(list1)):

       list1.append(list1[i]*list2[i])

   return list1

SECOND SOLUTION

def multLists(list1,list2):

   newlist = [ ]

   for i in range(len(list1)):

       newlist.append(list1[i]*list2[i])

   return newlist

Explanation:

First we define the function and call it MultLists. Then using a for statement, we loop through the list the number of times that is equivalent to the length of the list1. In the first solution, we append the element-wise multiplication in the two list and append this to list1. The return of the first solution, is list1 which contains list1 in addition to the product of the elements from list1 and list2

In the second solution, we create a new list, and using the append function, we populate it with the values of the element-wise multiplication from the two lists. The return of the second solution, is a new containing only to the product of the elements from list1 and list2


Related Questions

HIGH SCHOOL

What are some benefits of the Internet? (select all that apply)

Answers

It’s helps you Check things
It keeps you updated

Answer:

A. ease of communication

B. email

C. collaboration

Explanation:

:)

HIGH SCHOOL

An application ________ is anyone who writes a computer application for one or more platforms.

Answers

Answer:

An Application Programmer

Explanation:

A Programmer is a professional who writes applications for the computer on a platform.

HIGH SCHOOL

Which windows utility should you use to organize the files on your disk to improve efficiency?

Answers

Disk Defragmenter, is a windows utility that rearranges the records and unused space on the PC's hard disk so that the operating system accesses data more rapidly and projects run quicker. Disk Defragmenter keeps running on a timetable, yet you can likewise break down and defragment your disk and drives manually.

COLLEGE

Develop a Matlab program that allows you to plot the entropy of a source with variable output probabilities. We wish to observe that the maximum source entropy does indeed occur when the source outputs are equally likely. Start with a simple two-output source [s1; s2] with respective probabilities [a; 1-a] and plot the entropy as a function of the parameter a. Then consider more complex cases such as a three output source [s1; s2; s3] with respective probabilities [a; b; 1 - a - b]. Be creative with the manner in which the results are displayed.

Answers

Answer:

8m equals to 7n

Explanation:

Random Questions