sa 11 cs chapter 12

10. Computing Mean. Computing the mean of values stored in a tuple is relatively simple. The mean is the sum o f the values divided by the number o f values in the tuple. That is,

  # Code s = tuple(map(int, input(‘Enter a sequence of numbers : ‘).split())) # split() splits the input on whitespace, map() is converting the string types to integer types print(‘Mean of the above tuple is’, sum(s)/len(s)) # sum() gives the sum of any sequence

10. Computing Mean. Computing the mean of values stored in a tuple is relatively simple. The mean is the sum o f the values divided by the number o f values in the tuple. That is, Read More »

11. Mean of means. Given a nested tuple tup1 = ( (1, 2), (3, 4.15, 5.15), ( 7, 8, 12, 15)). Write a program that displays the means of individual elements of tuple tup1 and then displays the mean of these computed means . That is for above tuple, it should display as :

Mean element 1 : 1.5 ; Mean element 3 : 10.5; Mean element 2 : 4.1 ; Mean of means 5.366666 # Code tup1 = ((1, 2), (3, 4.15, 5.15), ( 7, 8, 12, 15)) c = 0 # sum() function gives sum of a sequence # mean = sum(tuple)/len(tuple) for i in range(len(tup1)): print(‘Mean

11. Mean of means. Given a nested tuple tup1 = ( (1, 2), (3, 4.15, 5.15), ( 7, 8, 12, 15)). Write a program that displays the means of individual elements of tuple tup1 and then displays the mean of these computed means . That is for above tuple, it should display as : Read More »