Beginners coding challenge:Python


Average of given 3 numbers
Take 3 numbers from the input and print the average of those numbers
Input:
2
4
9
Output:
3

Mathematically the average is 5.0 but they have asked for the output 3

Code:
num1 = int(input())
num2 = int(input())
num3 = int(input())
avg=(num1+num2+num3)/3
print(avg)

STDIN
2
4
9

OUTPUT:
5.0

0/2 test cases passed

https://onecompiler.com/challenges/3w7dby3mt/beginners-coding-challenge
Link for the challenge-question number 8

3 Answers

2 years ago by

@Sarvesh
Thanks for pointing out the mistake in problem description. We have corrected it.

Update:
Please note the answer should be int if it's an int i.e 5 instead 5.0.
So you may need to add int()

2 years ago by OneCompiler

Hey! The bug is not completely fixed. It is still showing 0/2 test cases passed

2 years ago by Sarvesh

n1 = int(input())
n2 = int(input())
n3 = int(input())
print((n1+n2+n3)/3)

2 years ago by Hari Devarapally