Answer to Question #102602 in Python for mlk

Question #102602
Write a python function that can find the average of given list of numbers. It prints all numbers whose values is less than the average on the screen.
1
Expert's answer
2020-02-10T03:50:53-0500


Solution:


def less_than_Avg(lis):
	avg = sum(lis) / len(lis)
	print("Average is:",int(avg))
	return [i for i in lis if i < avg]


def main():
	l = map(str, input("Enter elements of the list,separate with space: \n").split())
	lis=[]
	for i in l:
		if '.' in i:
			lis.append(float(i))
		else:
			lis.append(int(i))
	print("Number(s) whose value is less than the average:",*less_than_Avg(lis))


main()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS