Computer Science, asked by aishwarya2942, 10 months ago

How do you write a Python function to calculate and display the average of all the elements in a user defined tuple containing numbers?​

Answers

Answered by chiefprashant
4

Answer:

#Python

Explanation:

#lets assume that name of the tuple is ' a'

no_= a.length()

r = 0

for I in range(a):

r += I

avg = r/no_

print("Result : ", avg)

Answered by valeriy69
1

\small\mathsf\color{pink}{Solution\: using\: python\: 3}

import random

# populate a tuple

my_tuple = tuple(random.randrange(1, 100 + 1) for x in range(10))

def tup_avg(t):

return sum(t) / len(t)

print(f"average: {tup_avg(my_tuple)}")

\small\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions