Question: def validate _ float _ input ( prompt ) : while True: try: value = float ( input ( prompt ) ) return value except
def validatefloatinputprompt:
while True:
try:
value floatinputprompt
return value
except ValueError:
printInvalid input. Please enter a valid floating point number."
def main:
names
salaries
sentinel 'DONE'
printEnter employee names and salaries. Type 'DONE' when finished."
while True:
name inputEnter employee name or DONE to finish:
if name sentinel:
break
salary validatefloatinputEnter employee salary in thousands eg for :
names.appendname
salaries.appendsalary
if lensalaries:
printNo valid employee data entered."
return
averagesalary sumsalaries lensalaries
printf
Average Salary: $averagesalary :f
print
Employees with salaries within $ of the average:"
withinrange False
for name, salary in zipnames salaries:
if abssalary averagesalary:
printfName: name Salary: $salary :f
withinrange True
if not withinrange:
printNo employees have salaries within $ of the average."
if namemain:
main
The code above prints out the average salary and also those within a range of it So I almost have it but the last thing I need is to display every entered employee and their salary added under the text Employee and Salary Entered.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
