Trusted answers to developer questions

AKASH BAJWA

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

This ** fmean() method** is used to compute the float mean of input values. It converts input data into float values and calculates the arithmetic mean. This method is faster than the mean() method in older versions of Python.

Note: The new version of Python is version 3.8.

```
statistics.fmean(data)
```

It takes a single argument value:

: It can be an iterable or sequence.`data`

It returns an arithmetic mean as a floating-point value:

: If the dataset or data sequence is empty, then it raises a statistics error for a single data point.`StatisticsError`

# load statistice moduleimport statistics# demo data as listdata = [3.52, 4.0, 5.25]result = statistics.fmean(data)print(result)

In the code snippet above:

- Line 2: We load the statistics module in our program.
- Line 4: We create a list with demo data points.
- Line 5: We use the
`statistics.fmean()`

method to compute floating mean. - Line 6: We print
`result`

(mean value) on the console as a float value.

# load statistice moduleimport statistics# empty data sequence or listdata = []result = statistics.fmean(data) # raises exception# statistics.StatisticsError:# fmean requires at least one data pointprint(result)

In the code snippet above:

- Line 2: We load the statistics module in our program.
- Line 4: We create an empty list.
- Line 5: We use the
`statistics.fmean()`

method to compute the floating mean.

Due to an empty list, it raises the `statistics.StatisticsError`

error. The `fmean()`

requires at least one data point.

RELATED TAGS

fmean

python programming

statistics

communitycreator

CONTRIBUTOR

AKASH BAJWA

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses