## Example programming exercise

Write a program that reads a file that contains values of euro cents in each row and finds the sum (total amount) of euro cents and the value of smallest red coin (red coins are with values 1, 2 and 5). Cents are in the file *cents.txt,* where each line represents a coin (make the file by yourself). Find the sum of euro cents (valid euro coins are 1, 2, 5, 10, 20 and 50) and sum of unknown cents (the remaining numbers). Find the value of smallest red coin (1, 2, 5) or report about their absence.

For example, if the content of the file *cents.txt* is the following:

5 10 15 20 10

then the program output should be the following:

Sum of euro cents is 45 Sum of unknown cents is 15 Smallest red coin is 5

But if the content of the file *cents.txt* is the following:

10 15 4 20 25 50

then the program output should be the following:

Sum of euro cents is 80 Sum of unknown cents is 44 No red coins

You should follow these steps when writing your program:

- Read from file
*cents.txt*and store the cents into a list. Program shouldnâ€™t crash in case the file does not exist (use*try-except*). - Write a function
*eurocents*that takes the list with all cents as a parameter and finds and returns the sum of euro cents (1, 2, 5, 10, 20 and 50). - Use function
*eurocents*in the program to output the sum of euro cents and the sum of unknown cents. - Write a function
*red_coin*that takes the list with all cents as a parameter, finds the smallest red coin and returns its value. If there are no red coins then the function returns 0. - Use function
*red_coin*in the program to output the smallest red coin (1, 2, 5) or report about their absence.