Share your knowledge with other learners . . . Write As Guest

python में statistics module का mean() method का use दिए गए numeric data set का mean (average) calculate करता है।

Python statistics mean method

statistics.mean(data)

Parameters

  1. data | required : data जिसका हमें mean calculate करना है , आप इसमें numeric values की list या कोई भी iterator (list, tuple, set) pass कर सकते हैं।

  2. Return value : pass की गयी values के according float value return होती है।

Python statistics mean method Example

Copy Fullscreen Close Fullscreen Run
# Import statistics module.
import statistics

#pass data in list.
print('Calculate using list')
print(statistics.mean([23,34,546,67]))
print(statistics.mean([2,3,4,5]))

#pass data in tuple.
print('Calculate using tuple')
print(statistics.mean((23,34,546,67)))
print(statistics.mean((2,3,4,5)))

#pass data in set.
print('Calculate using set')
print(statistics.mean({23,34,546,67}))
print(statistics.mean({2,3,4,5}))
Output
C:\Users\Rahulkumar\Desktop\python>python mean.py
Calculate using list
167.5
3.5
Calculate using tuple
167.5
3.5
Calculate using set
167.5
3.5

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers