Python Homework - Py Me Up, Charlie
it first imports the needed libraries
it then creates the needed integers, strings, dictionaries and lists
Next, it creates the path to collect data from the Resources folder, opens it and reads it in
After reading the first row as a header, it loops through the data to get:
The net total amount of "Profit/Losses" from month-to-month over the entire period
find the current row value and the difference and then store the current value as the previous value
The greatest increase in profits (date and amount) over the entire period
The greatest decrease in losses (date and amount) over the entire period
The total number of months included in the dataset
The average of the changes in "Profit/Losses" over the entire period
It then prints the summary to the screen and creates the text file with the same summary
it first imports the needed libraries.
it then creates the needed integers, strings, dictionaries and lists.
Next, it creates the path to collect data from the Resources folder, opens it and reads it in.
After reading the first row as a header, it loops through the data to get:
A complete list of candidates who received votes
The total number of votes each candidate won
every time it come across a new name not already in dictionary, it adds a new key for the candidates name
othewise, if they are in the dictionary, it increases their vote count by one
After that, it loops through the values and converts them to percent
It then creates a list of the votes and a list of the candidates
It next finds the maximum num of votes and the index for the winner based on the maximum number of votes
Finally, it prints the summary to the screen and creates the text file with the same summary