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

What is mode?

mode का मतलब है किसी dataset में present most frequent value means वो value जो सबसे ज्यादा बार appear हुई है।

Python statistics mode Method Syntax

statistics.mode(data)

Parameters

  1. data | required : data जिसका हमें mode calculate करना है , आप इसमें values की list / tuple pass कर सकते हैं।

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

Python statistics mode Method Exmaple

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

#pass data in list.
print('Calculate using list')
print(statistics.mode([3,4,4,3, 4]))
print(statistics.mode(['red', 'green', 'blue', 'red']))

#pass data in tiuple.
print('Calculate using tuple')
print(statistics.mode((3,3,3,3,4,4,3, 4)))
Output
C:\Users\Rahulkumar\Desktop\python>python mode_test.py
Calculate using list
4
red
Calculate using tuple
3

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