The problem statement is: Problem Statement: You will write a program to analyze employee salaries. Create a file named EmployeeSalaries.txt. Copy the numbers given below into the EmployeeSalaries.txt file. Make sure to save this file in the directory where you create your python file. Write a program that opens the EmployeeSalaries.txt file and reads the salaries into a list. The program should output the following information in this order: The lowest salary in the list The highest salary in the list The total of all salaries in the list The average of all salaries in the list I have the txt file saved. I can figure out the min & max but not total and average def main(): # declare variables empSalaries = '' try: # Open file for reading inputFile = open('EmployeesSalaries.txt', 'r') # read file into list EmployeeList = inputFile.readlines() # strip out the \n from file for i in range(len(EmployeeList)): EmployeeList[i] = EmployeeList[i].rstrip('\n') print('The lowest salary is: $', min(EmployeeList)) print('The highest salary is: $', max(EmployeeList)) except IOError: print('File not FOund!!') except: print('Error Occurred!') main()
The problem statement is:
Problem Statement:
You will write a
Write a program that opens the EmployeeSalaries.txt file and reads the salaries into a list. The program should output the following information in this order:
- The lowest salary in the list
- The highest salary in the list
- The total of all salaries in the list
- The average of all salaries in the list
I have the txt file saved.
I can figure out the min & max but not total and average
def main():
# declare variables
empSalaries = ''
try:
# Open file for reading
inputFile = open('EmployeesSalaries.txt', 'r')
# read file into list
EmployeeList = inputFile.readlines()
# strip out the \n from file
for i in range(len(EmployeeList)):
EmployeeList[i] = EmployeeList[i].rstrip('\n')
print('The lowest salary is: $', min(EmployeeList))
print('The highest salary is: $', max(EmployeeList))
except IOError:
print('File not FOund!!')
except:
print('Error Occurred!')
main()
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images