Question #63703

Write a function called manipulate_data which will act as follows:

When given a list of integers, return a list, where the first element is the count of positives numbers and the second element is the sum of negative numbers.

NB: Treat 0 as positive.
1

Expert's answer

2016-12-04T04:28:11-0500

Answer on Question#63703 – Programming & Computer Science | Python


def manipulate_data(my_list):
    count_of_positive = 0
    sum_of_negative = 0
    for number in my_list:
        if number < 0:
            sum_of_negative += number
        else:
            count_of_positive += 1
    return [count_of_positive, sum_of_negative]


http://www.AssignmentExpert.com

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS