Average time to commute

Problem Statement

Employees of Company ABC are required to work for five days in a week. The company would like to know the average time to commute of an employee in a week.

Write a program to calculate the average time to commute to office, for the given commute times in a week.

If a, b, c, d, and e are the times to commute for the five days in a week, then the formula to find the average time to commute is

(a + b + c + d + e) / 5

Input

The first line of input consists of five integer values, separated by space, where each integer represents the time to commute for the day in minutes.

Each value (time of commute) >= 0.

Output

Print the average time to commute, rounded to the next integer.

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 ✍

averageCommuteTime() has five parameters: a, b, c, d, and e. The challenge is to complete the averageCommuteTime() function to return an integer value representing the average of the given arguments.

You may use round() builtin function to round the average to nearest integer.

Example 1

Test input

10 12 11 13 11

Test output

11

Explanation

Sum = 10 + 11 + 12 + 13 + 11
    = 57
Average = 57 / 5
        = 11.2
Average rounded to nearest integer = 11

Python Program

# Complete the following function
def averageCommuteTime(a, b, c, d, e):







# Boilerplate code - Do not edit the following
def main():
    a, b, c, d, e = [int(item) for item in input().split()]
    print(averageCommuteTime(a, b, c, d, e))

if __name__ == "__main__":
    main()

Input and Outputs 1

120 100 130 410 210
194

Input and Outputs 2

1 1 1 2 1
1

Input and Outputs 3

10 11 12 13 12
12

# Complete the following function
def averageCommuteTime(a, b, c, d, e):
    # Find average
    sum = a + b + c + d + e
    average = sum / 5
    # Round to nearest integer
    average = round(average)
    return average

# Boilerplate code - Do not edit the following
def main():
    a, b, c, d, e = [int(item) for item in input().split()]
    print(averageCommuteTime(a, b, c, d, e))

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