Python Program to find the average of 5 numbers using a lambda function


In this program, you will learn how to find the average of 5 numbers using a lambda function in Python.


x = lambda a, b, c, d, e: (a + b + c + d + e) / 5

Example: How to find the average of 5 numbers using a lambda function in Python

x = lambda a, b, c, d, e: (a + b + c + d + e) / 5

a = int(input("Enter first number:"))
b = int(input("Enter second number:"))
c = int(input("Enter third number:"))
d = int(input("Enter fourth number:"))
e = int(input("Enter fifth number:"))

result = x(a, b, c, d, e)
print("Average is:", result)

Output:

Enter first number:10
Enter second number:20
Enter third number:30
Enter fourth number:40
Enter fifth number:50
Average is: 30.0

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.