jeudi 10 décembre 2020

Beginner Python Functions & Loops [closed]

I have been stuck at this question for the past day and would appreciate any help!

  1. In a firm, employees are paid based on their years of work experience.

Work Experience(years) Salary 0-3 $25000 4-8 $50000 9-13 $75000 14-20 $100000 more than 20 years $150000

There are 4 employees from the same family with experience of 8 years, 25 years, 15 years and 45 years. Using the function created in a), and a loop, calculate and print the total income of this family. Then, let the user know if the family’s total income is more than $150,000. You do not need to take any inputs from the user for this question.

I have already come up with this function so far,

def salary(experience):
if experience <=3.9:
    return "$25000"
elif experience <=8.9:
    return "$50000"
elif experience <=13.9:
    return "$75000"
elif experience <=20:
    return "$100000"
else:
   return "$150000"

and I now need to embed it in a loop but can't for the life of me! Any advice would be appreciated! Thank you

Aucun commentaire:

Enregistrer un commentaire