Search this site
Embedded Files
Python by Examples
  • Tutorial
    • Download & Install
      • Install Python on Ubuntu Linux
    • Help
  • Strings
    • comparison
    • Get safe character string
    • str() and repr()
  • argparse
    • ValueError
  • Biopython
    • Examples
      • GC content
      • Inverse seq
      • Read/write fasta
    • Install Biopython
  • Data structures
    • Dictionary
      • get keys
      • Multiple keys
    • Lists
      • 0-based indices
      • List element frequencies
      • Median
  • Debugging
  • Error
    • TabError
  • Error handling
    • Check Python version
    • Type checking (raise)
  • File operations
    • File commands
      • get module path
      • os.rename vs shutil.move
      • tar
    • Files: read & write
      • gzip compression
      • Read csv files
      • strip
  • Functions
  • Loops
    • For loops
    • if else ...
    • List Comprehension
  • Math
    • DataFrame
    • Machine Learning
      • Kernel PCA
    • Matrix Calculations
      • Plot
    • Statistics
    • types
  • Packages
    • Create own modules
    • Import Modules
      • Check modul version
    • Install packages
    • python script
  • Parallel processing
    • pool.map - multiple arguments
  • Plot
    • barplot
    • colors
      • rgb2hex
    • matplotlib
      • colormaps
      • Error
      • Transparent colors
  • Print
    • Error
  • System
    • Environment
    • External Commands
  • Time
  • WWW
    • CGI script
    • Download webpage
    • Graphics
Python by Examples

Median

Lists (data structures)

get min, max, sum, mean, and median of a list containing numbers

import numpy  

# create a list

x=[2,3,4,8]


min(x)

 2

max(x)

 8

sum(x)

 17

numpy.mean(x)

 4.25

numpy.median(x)

 3.5

numpy.percentile(x, 25)

 2.75

numpy.percentile(x, 75)

 5.0

Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse