Write a Python program to find the addition, multiplication and average of any 3 numbers. (Eg, 3,6,8) Also write code to check if the average is an odd or an even number. I will mark the answer brainliest
Answers
Answered by
4
def add(nums):
_sum = 0
for n in nums:
_sum += n
return _sum
def prod(nums):
_prod = 1
for n in nums:
_prod *= n
return _prod
avg = lambda nums: add(nums) / len(nums)
even_odd = lambda n: "even" if n % 2 == 0 else "odd"
nums = [float(n) for n in input("enter 3 nums: ").split()]
avg_nums = avg(nums)
print(f"Sum: {add(nums)}\nProduct: {prod(nums)}\nAvg: {avg_nums:.2f}")
print(f"The avg is {even_odd(avg_nums)}")
Similar questions
Physics,
4 months ago
Political Science,
4 months ago
Math,
8 months ago
Biology,
11 months ago
English,
11 months ago