Q. Write a program to calculate the average of a tuple element by calculating its sum and dividing it with the count of the elements. Then compare it with the mean obtained using mean() of statistics module.
Answer :-
import statistics tup = eval(input("Enter a tuple :-")) sum = sum(tup) print("Average =", sum / len( tup )) print("Mean =", statistics.mean( tup ) )
Output:-
Enter a tuple :-(3,7,8,12,15,19,21,25)
Average = 13.75
Mean = 13.75
Average = 13.75
Mean = 13.75
>>>
Enter a tuple :-(1,2,3,4,5,6,7,8,9,10)
Average = 5.5
Mean = 5.5
>>>
Thanks
ReplyDeleteWelcome : )
DeleteTHANKYOU<3
ReplyDeleteWelcome 😊
Deletei clicked on question 13 but here it is question 14 please fix it love your site btw
ReplyDeletePlease tell me question no. 14.
DeleteThank you for what you provide us it is very useful and helpful for us 😊
ReplyDeleteWelcome : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )