Increment Salary of Employees

Problem Statement

At the end of the financial year, Company ABC wants to increase the salary of its employees by a specific percentage.

Write a program to calculate the new salary for the employees.

Input

The first line of input consists of an integer representing the percentage of increment.

The second line of input consists of N space separated integer values representing the salaries of N employees in the company.

Output

Print the list with updated salary for the N employees.

As is

The boilerplate code is already there to read the inputs from user, in the main() function. Do not edit this code.

To do ✍

calculateNewSalary() has two parameters: percentage, and salary. Also, the code is already written to iterate over the list, and return the list. The challenge is to write the formula to compute the

Example 1

Test input

20
100000 140000

Test output

[120000, 168000]

Explanation

20% increment of 100000 is 100000 + 0.2*100000 which is 120000.

20% increment of 140000 is 140000 + 0.2*140000 which is 168000.

Example 2

Test input

10
251240

Test output

[276364]

Python Program

# Complete the following function
def calculateNewSalary(percentage, salaries):
    new_salaries = []
    for salary in salaries:
        new_salary =  #complete this formula
        new_salaries.append(int(new_salary))
    return new_salaries

# Boilerplate code - Do not edit the following
def main():
    percentage = int(input())
    salaries = [int(item) for item in input().split()]
    print(calculateNewSalary(percentage, salaries))

if __name__ == "__main__":
    main()

Input and Outputs 1

10
251240
[276364]

Input and Outputs 2

5
100 200 300 0 142
[105, 210, 315, 0, 149]

Input and Outputs 3

12
526 321
[589, 359]

Input and Outputs 4

0
142 235
[142, 235]

# Complete the following function
def calculateNewSalary(percentage, salaries):
    new_salaries = []
    for salary in salaries:
        new_salary =  #complete this formula
        new_salaries.append(int(new_salary))
    return new_salaries

# Boilerplate code - Do not edit the following
def main():
    percentage = int(input())
    salaries = [int(item) for item in input().split()]
    print(calculateNewSalary(percentage, salaries))

if __name__ == "__main__":
    main()
show answer
main.py
⏵︎ Run Tests
Reset
Download
×
Code copied to clipboard successfully 👍