Create a function positive_sum(my_list) that would calculate the sum of positive values in the list. 1.1. Create a variable that will store your sum and initialize it with zero. 1.2. Go through your list with a loop Check if the current value is positive Add positive value to resulting value 1.3. Return the calculated result

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question

_Python_

  1. Create a function positive_sum(my_list) that would calculate the sum of positive values in the list.

    1.1. Create a variable that will store your sum and initialize it with zero.

    1.2. Go through your list with a loop

    • Check if the current value is positive

    • Add positive value to resulting value

    1.3. Return the calculated result

Hints:

  • we add the value to the result if the value is positive and otherwise we do nothing.
  • use if inside the loop
  • the loop should be going over all values in the list
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning