Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please, need help. Please complete the following program. In the write-up, it ta

ID: 644565 • Letter: P

Question

Please, need help.

Please complete the following program. In the write-up, it talks about "computer programming language of your choice" and "arrays". Of course, you should choose Python as the language. And if you do, Python does not support arrays, so use a list instead.

Write a simple program in the computer programming language of your choice. The program shall have two functions (methods): a main function and a helper function. The main function shall do the following:

The helper function shall do the following:

The end result is that the program prints out the value 100.

Notes: Use local variables rather than global variables, if supported in the implementation language.

Please make sure that you add the standard header comment to this script.

1/ program runs and produces the expected result
1/ program consists of two functions: a main and a helper
1/ main declares an array (list) as a local variable
1/ main uses a loop to fill the array with values
1/ main passes the array to helper function
1/ main prints out the value returned by the helper function
1/ helper function loops over the array parameter
1/ helper function calculates the total of the selected elements of the array
1/ helper function returns the total
1/ appropriate comments in the code

Explanation / Answer

def solve(l):
   sum = 0
   for i in range(len(l)):
       if (l[i] % 2 == 1):
           sum += l[i]
       else:
           continue
   return sum

def main():
   l = []
   for i in range(1,21):
       l.append(i)
   ans = solve(l)
   print(ans)
  
main()