Create travillian-quiz-1.py

This is quiz 1 for my Java class, to demonstrate my basic programming capacities in a language of my choice--here, Python.

The assignment is:

Quiz 1: Basic Programming Competence

Quiz 1 is very short and straight forward. When I have a student that wants to challenge the CSC 110 prerequisite for CSC 142, I ask them to write a simple program for me. I consider this request something that can be easily completed by someone who successfully completes CSC 110. This quiz is similar to the CSC 110 prerequisite challenge.

Please complete the following program.

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:

declare an array that can hold 15 integer values

use a loop to put the integer values 1, 2, 3, …, 13, 14, 15 into the array

pass the array to the helper function which will return an integer value

print out the value returned by the helper function

The helper function shall do the following:

traverse the array values found in the array, totaling the values that are odd or a multiple of 3.

return the sum of those values.

The end result is that the program prints out the value 82.

Notes:

Use local variables rather than global variables, if supported in the implementation language.

If you implement this in Python, you should use a list, since Python does not support arrays, per se.

1 + 3 + 5 + 6 + 7 + 9 + 11 + 12 + 13 + 15 = 82

Notice that 3, 9, and 15 are not added twice.

Submission

The file that you submit shall be ready to use (be compiled or interpreted). This includes having an appropriate file extension. If the language that you are using requires it, submit two files with one function in each file; otherwise submit one file containing both function.

Both functions in your code should have brief comments that precede them describing the actions of those functions. In this case, the comments can be as simple as "main function" and "helper function".

Add a header comment to your program. The header comment shall include your name and this homework designation (Quiz 1: Basic Programming Competence).

Grading Rubric

10 points:

1/ program runs and produces the expected result

1/ submission conforms to write-up: 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 appropriate elements of the array

1/ helper function returns the total

1/ appropriate comments in the code