Python Code
2 simple problems
1. Write a Python program that will read a list of temperatures from a data file you created called tempfile.txt and display the highest two temperatures. For example
Your program displays:
The highest two temperatures found are 89 and 70
When tempfile.txt contains
32
15
65
89
44
59
70
Hint: First read the temperatures into a list, and then loop through the llst looking for the two largest values without using built-in functions such as max or sort. then rewrite the program using the built-in function sort, and finally ,rewrit it the thir time using the built-in function max.
2. Write a python program that reads a data file you created called people.txt This data file will consist of a number of lines, with each line containing a last name and a hair color, where the name and hair color are separated by a comma. Your program should then display the number of people with each hair color. For instance:
Red Hair: 2
Blond Hair: 3
Black Hair: 1
Brown Hair: 1
When people.txt contains
Jones, Red
Smith, Blond
Alan, Black
Thompson, Brown
Jasper, Blond
Quiton, Red
Harris, Blond
Hint: First try it using dictionaries where the key is the hair color and the value is the number of time it has been seen. then rewrite the program where you use two lists, one containing the hair colors and one containing the number of time the hair colors have been encountered.
*You don't necessarily need to solve these using the hints, I just threw those in there since they were on the practice page. These should be relatively short programs, I need this to use as a study guide for my proficiency exam where we will be asked a similar problem and will ne