Python program that opens a file & prints the sum, the count of even & odd numbers stored in the file.

Write a program that opens file numbers.txt which contains a series of names followed by integers. The program read the data from the file and prints total number of integers, the sum of all the numbers, the count of even numbers, and the average of all the numbers.

For example, if the input file contains the following text:

Dan 3

Cordelia 7

Tanner 14

Mellany 13

Curtis 4

Amy 12

Nick 6

Then the function should produce the following console output:


file = open(‘numbers.txt’, ‘r’)
Lines = file.readlines()
count = 0
evens = 0
sums = 0
for line in Lines:
     count += 1
     sums += int(aa[1])
     if((int(aa[1]))%2 == 0):
         evens += 1

print(“count = “,count)
print(“sum = “,sums)
print(“evens = “,evens)
print(“average = “,sums/count)