Compute Annual Sales

Problem Statement

Company ABC has quarterly sales data. It wants to compute the total annual sales.

Write a program to find the total annual sales for the company.

Input

The first line of input consists of four float values separated by spaces representing the sales of the respective quarters in million dollars.

Output

Print a float value representing the annual sales from the given quarters’ sales values.

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 ✍

computeAnnualSales() has one four parameters for the sales in the first, second, third, and fourth quarter. Compute the annual sales, and return the result.

annualSales = q1 + q2 + q3 + q4

Example 1

Test input

2.5 3.1 4.2 1.8

Test output

11.6

Explanation

The sum of the sales from the four quarters is 2.5 + 3.1 + 4.2 + 1.8 which is 11.6.

Example 2

Test input

5 6 1.3 7.1

Test output

19.4

Python Program

# Complete the following function
def computeAnnualSales(q1, q2, q3, q4):
    return 

# Boilerplate code - Do not edit the following
def main():
    q1, q2, q3, q4 = [float(item) for item in input().split()]
    print(round(computeAnnualSales(q1, q2, q3, q4), 2))

if __name__ == "__main__":
    main()

Input and Outputs 1

2.5 3.1 4.2 1.8
11.6

Input and Outputs 2

0 5 1 2
8.0

Input and Outputs 3

0 0 0 0
0.0

Input and Outputs 4

2.3 -1.6 6.3 -2.3
4.7

# Complete the following function
def computeAnnualSales(q1, q2, q3, q4):
    return q1 + q2 + q3 + q4

# Boilerplate code - Do not edit the following
def main():
    q1, q2, q3, q4 = [float(item) for item in input().split()]
    print(round(computeAnnualSales(q1, q2, q3, q4), 2))

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