how to use matplotlib in python 3 code example

Example 1: how to import matplotlib in python

import matplotlib

Example 2: how to use timeit in python 3

import timeit
import_module = "import random"
testcode = ''' 
def test(): 
    return random.randint(10, 100)
'''
print(timeit.repeat(stmt=testcode, setup=import_module))

Example 3: print in python 2

# Print is a keyword in python2, so it works more like this
print ""

# Also like this
print 1+1

Example 4: how to use def in python

def functionName(variable):
  //function content

Example 5: Use matplotlib in python

import matplotlib.pyplot as plt # Import the matplotlib module
from matplotlib import style # Optionally you dont need to use style
style.use('ggplot') # Just for style

x = [10, 20, 30, 40, 50] # Get points to plot on graph

plt.plot(x) # We want to plot x on our graph
plt.show()