How to Apply the mode() Function of the statistics Module in Python (Example Code)
This tutorial explains how to apply the mode function of the statistics module in Python.
Creation of Example Data
x = [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7] # Constructing a list in Python print(x) # Displaying the example list # [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7] |
x = [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7] # Constructing a list in Python print(x) # Displaying the example list # [1, 3, 3, 7, 1, 3, 5, 1, 2, 2, 1, 2, 1, 3, 1, 7]
Example: Applying mode() Function of statistics Module
import statistics # Load statistics |
import statistics # Load statistics
print(statistics.mode(x)) # Get mode of list # 1 |
print(statistics.mode(x)) # Get mode of list # 1