Question: Part 1 5 , 6 , 8 , 7 , 8 , 9 , 2 , 3 , 2 , 8 , 6 , 9

Part 1
5,6,8,7,8,9,2,3,2,8,6,9,9,4,5,8,9,1,8,6,
10,8,8,4,5,5,3,7,5,8,1,3,1,9,5,9,8,5,2,1,7,
10,4,1,3,6,5,5,2,3,7,4,2,3,5,8,9,8,3,3,1,
5,7,3,5,3,8,6,9,10,9,9,2,10,2,9,2,5,6,4,10,
9,5,8,3,4,2,4,7,2,3,1,9,2,7,3,3,4,6,2]
write a program that iterates over the list of numbers and writes each number to a separate line in the file. The writelines method can not be used. The file should be created in your home directory and named numbers.txt. Display a message to the user after the numbers have been written to the file successfully. Use utf-8 character encoding.
Here is a sample run of the program:
The integer list has been written to the file /Users/jeffa/numbers.txt
Part 2
Write a program to read the file numbers.txt created in part 1 that was saved to your home directory. As you read each number, keep track of how many times each of the numbers appear in the file (use a dictionary with the number as the key and count as the value). Print the count of each number and the sum of all the numbers in the file.
Here is a sample run of the program:
Number 5 is in the list 14 times.
Number 6 is in the list 7 times.
Number 8 is in the list 13 times.
Number 7 is in the list 7 times.
Number 9 is in the list 13 times.
Number 2 is in the list 12 times.
Number 3 is in the list 8 times.
Number 4 is in the list 8 times.
Number 1 is in the list 7 times.
Number 10 is in the list 5 times.
The total of all the numbers in the list is: 537

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!