Short Python Exercises by D@CC 2024ISep03 Do the following exercises without peeking at the source shown below. 1. He wants to know his average expenses for each semester. Using two for loops, calculate John’s average expenses for the first semester (January to June) and the second semester (July to December). monthly_spending = [2689.56, 2770.38, 2394.04, 2099.91, 3182.20, 3267.12, 1746.83, 2545.72, 3328.20, 3147.30, 2462.61, 3890.45] 2. Do the same as exercise 1, but using a function that is passed the list and the number of the "beginning month" 3. Create a list containing all the friends, but removing duplicates. paul_friends = ["Mary", "Tim", "Mike", "Henry"] tina_friends = ["Tim", "Susan", "Mary", "Josh"] 4. Let’s try counting the number of occurrences in a list. The list below represent the results of a poll where students were asked for their favorite programming language: poll_results = ["Python", "Java", "Javascript", "Python", "Javascript", "Python", "C", "Python", "Python", "C", "Javascript"] 5. Print the results of Exercise 4 twice, first in alphabetical order of programming langue, second in order of occurrences, most first. 6. Three friends are playing a game, where each player has three rounds to score. At the end, the player whose total score (i.e. the sum of each round) is the highest wins. Consider the scores below (formatted as a list of tuples). The scores are listed below. Mikes score for rounds 1, 2 and 3 are 10,8 and 6: scores = [('Mike', 10), ('Mike', 8), ('Mike', 6), ('John', 7), ('John', 8), ('John', 5), ('Tom',3), ('Tom', 8), ('Tom', 9)] 7. Do exercise 6 for the following scores that are slightly mixed up. Notice that Mike's third score is listed after John's first score. The results should still be the same, of course. scores = [('Mike', 10), ('Mike', 8), ('John', 7), ('Mike', 6), ('John', 8), ('John', 5), ('Tom',3), ('Tom', 8), ('Tom', 9)] 8. Print the winner of each of the three rounds (highest score wins). Use data for Exercise #7. Source: https://learnpython.com/blog/python-practice-for-beginners/ /Exercises_2024ISep03.txt