6. Program to input salary of an employee and display the salary that the person will receive for each
of the next 5 years if he gets an increment of 10% every year.
python (in loop)
unnecessary answer will be report.
Answers
def increment(salary):
salaries = []
new_salary = salary
for _ in range(5):
new_salary *= 1.1
salaries.append(round(new_salary, 2))
return "\n".join([f"Year {idx + 1}: {salary}" for idx, salary in enumerate(salaries)])
print(increment((salary := float(input("salary: ")))))
Answer:
Use Python 3
def increment(salary):
def increment(salary):salaries = []
def increment(salary):salaries = []new_salary = salary
def increment(salary):salaries = []new_salary = salaryfor _ in range(5):
def increment(salary):salaries = []new_salary = salaryfor _ in range(5):new_salary *= 1.1
def increment(salary):salaries = []new_salary = salaryfor _ in range(5):new_salary *= 1.1salaries.append(round(new_salary, 2))
def increment(salary):salaries = []new_salary = salaryfor _ in range(5):new_salary *= 1.1salaries.append(round(new_salary, 2))return "\n".join([f"Year {idx + 1}: {salary}" for idx, salary in enumerate(salaries)])
def increment(salary):salaries = []new_salary = salaryfor _ in range(5):new_salary *= 1.1salaries.append(round(new_salary, 2))return "\n".join([f"Year {idx + 1}: {salary}" for idx, salary in enumerate(salaries)])print(increment((salary := float(input("salary: ")))))