Write a python program which will ask user to enter 3 numbers. Your program will output the sum and average of these 3numbers.your program will also output the largest number, the smallest number of these three. For exampleif user enter 2,10,3 than your program will output, For number 2,10,3 sum is 15,average is 5,the largest number is 10 and the smallest number is 2. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Write a python program which will ask user to enter 3 numbers. Your program will output the sum and average of these 3numbers.your program will also output the largest number, the smallest number of these three. For exampleif user enter 2,10,3 than your program will output, For number 2,10,3 sum is 15,average is 5,the largest number is 10 and the smallest number is 2.

28th Jan 2017, 11:03 PM
Parita Shah
Parita Shah - avatar
4 Answers
+ 1
# you may want to experiment with float vs int # to see the difference in allowed user input. # also .format() is a useful feature for your problem. user_num = input('Enter 3 number values as digits') try: data= sorted(map(float,user_num.split())) print(''' The average value is {0} The smallest is {1} The largest is {2} '''.format(sum(data)/len(data),data[0],data[-1])) except: print('some of your input is invalid')
29th Jan 2017, 1:51 AM
richard
- 1
Here's the code you're looking for: nums = input("""input three numbers(comma and space separated) >>> """) nums = nums.split(", ") nums = list(map(int, nums)) print("Sum: " + str(sum(nums)) + ", Average: " + str(sum(nums)/len(nums)) + ", Highest Number: " + str(max(nums)) + ", Lowest Number: " + str(min(nums)))
28th Jan 2017, 11:44 PM
Kaden
Kaden - avatar
- 2
Is this a question?
28th Jan 2017, 11:25 PM
Garfield
Garfield - avatar
- 2
If is it a question about lasagna or ravioli, I will answer it :) I am an expert🤗😄
28th Jan 2017, 11:26 PM
Garfield
Garfield - avatar