Skip to content

Instantly share code, notes, and snippets.

@decisionstats
Created December 11, 2015 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save decisionstats/ce2c16ee98abcf328177 to your computer and use it in GitHub Desktop.
Save decisionstats/ce2c16ee98abcf328177 to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Numerical Operations"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2+3+5\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"67"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"66-3-(-4)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"96"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"32*3"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"8"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2**3 #2 raised to power of 3"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"14.333333333333334"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"43/3"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"32//3 #Gives Numerator"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"44%3 #Gives remainder"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## For Loops\n",
"#### See https://docs.python.org/3/tutorial/controlflow.html"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"6\n",
"12\n",
"18\n",
"24\n"
]
}
],
"source": [
"#numbers from 8 to 30 increment 6\n",
"for x in range(0, 30,6):\n",
" print (x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Functions"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def myfirstfunction(x):\n",
" y=x**3+3*x+20\n",
" print(y)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8080\n"
]
}
],
"source": [
"myfirstfunction(20)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20\n",
"254\n",
"1784\n",
"5906\n",
"13916\n"
]
}
],
"source": [
"for x in range(0, 30,6):\n",
" myfirstfunction (x)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def mynewfunction(x,y):\n",
" z=x**3+3*x*y+20*y\n",
" print(z)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"70\n"
]
}
],
"source": [
"mynewfunction(1,3)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1150\n"
]
}
],
"source": [
"mynewfunction(10,3)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'In': ['',\n",
" '2+3+5',\n",
" '66-3-(-4)',\n",
" '2^3',\n",
" '3^3',\n",
" '44%%3',\n",
" '44%3',\n",
" '43/3',\n",
" '32*3',\n",
" '2**3',\n",
" '32//3',\n",
" 'for i in 1:30\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print %i',\n",
" 'for i in range(1,30):\\n print %(i)',\n",
" 'for i in range(1,30):\\n print % (i)',\n",
" 'for i in range (1,30):\\n print % (i)',\n",
" 'for x in range(0, 30):\\n print % (x)',\n",
" 'for x in range(0, 30):\\n print (x)',\n",
" 'for x in range(0, 30,6):\\n print (x)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'myfirstfunction(20)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n myfirstfunction (x)',\n",
" 'def myfirstfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def mynewfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'mynewfunction(1,3)',\n",
" 'mynewfunction(10,3)',\n",
" 'locals()'],\n",
" 'Out': {1: 10,\n",
" 2: 67,\n",
" 3: 1,\n",
" 4: 0,\n",
" 6: 2,\n",
" 7: 14.333333333333334,\n",
" 8: 96,\n",
" 9: 8,\n",
" 10: 10},\n",
" '_': 10,\n",
" '_1': 10,\n",
" '_10': 10,\n",
" '_2': 67,\n",
" '_3': 1,\n",
" '_4': 0,\n",
" '_6': 2,\n",
" '_7': 14.333333333333334,\n",
" '_8': 96,\n",
" '_9': 8,\n",
" '__': 8,\n",
" '___': 96,\n",
" '__builtin__': <module 'builtins' (built-in)>,\n",
" '__builtins__': <module 'builtins' (built-in)>,\n",
" '__doc__': 'Automatically created module for IPython interactive environment',\n",
" '__loader__': None,\n",
" '__name__': '__main__',\n",
" '__package__': None,\n",
" '__spec__': None,\n",
" '_dh': ['/home/ajay'],\n",
" '_i': 'mynewfunction(10,3)',\n",
" '_i1': '2+3+5',\n",
" '_i10': '32//3',\n",
" '_i11': 'for i in 1:30\\n print i',\n",
" '_i12': 'for i in 1:30:\\n print i',\n",
" '_i13': 'for i in 1:30:\\n print i',\n",
" '_i14': 'for i in range(1,30):\\n print i',\n",
" '_i15': 'for i in range(1,30):\\n print i',\n",
" '_i16': 'for i in range(1,30):\\n print %i',\n",
" '_i17': 'for i in range(1,30):\\n print %(i)',\n",
" '_i18': 'for i in range(1,30):\\n print % (i)',\n",
" '_i19': 'for i in range (1,30):\\n print % (i)',\n",
" '_i2': '66-3-(-4)',\n",
" '_i20': 'for x in range(0, 30):\\n print % (x)',\n",
" '_i21': 'for x in range(0, 30):\\n print (x)',\n",
" '_i22': 'for x in range(0, 30,6):\\n print (x)',\n",
" '_i23': 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" '_i24': 'myfirstfunction(20)',\n",
" '_i25': 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" '_i26': 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" '_i27': 'for x in range(0, 30,6):\\n myfirstfunction (x)',\n",
" '_i28': 'def myfirstfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" '_i29': 'def mynewfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" '_i3': '2^3',\n",
" '_i30': 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" '_i31': 'mynewfunction(1,3)',\n",
" '_i32': 'mynewfunction(10,3)',\n",
" '_i33': 'locals()',\n",
" '_i4': '3^3',\n",
" '_i5': '44%%3',\n",
" '_i6': '44%3',\n",
" '_i7': '43/3',\n",
" '_i8': '32*3',\n",
" '_i9': '2**3',\n",
" '_ih': ['',\n",
" '2+3+5',\n",
" '66-3-(-4)',\n",
" '2^3',\n",
" '3^3',\n",
" '44%%3',\n",
" '44%3',\n",
" '43/3',\n",
" '32*3',\n",
" '2**3',\n",
" '32//3',\n",
" 'for i in 1:30\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print %i',\n",
" 'for i in range(1,30):\\n print %(i)',\n",
" 'for i in range(1,30):\\n print % (i)',\n",
" 'for i in range (1,30):\\n print % (i)',\n",
" 'for x in range(0, 30):\\n print % (x)',\n",
" 'for x in range(0, 30):\\n print (x)',\n",
" 'for x in range(0, 30,6):\\n print (x)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'myfirstfunction(20)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n myfirstfunction (x)',\n",
" 'def myfirstfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def mynewfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'mynewfunction(1,3)',\n",
" 'mynewfunction(10,3)',\n",
" 'locals()'],\n",
" '_ii': 'mynewfunction(1,3)',\n",
" '_iii': 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" '_oh': {1: 10,\n",
" 2: 67,\n",
" 3: 1,\n",
" 4: 0,\n",
" 6: 2,\n",
" 7: 14.333333333333334,\n",
" 8: 96,\n",
" 9: 8,\n",
" 10: 10},\n",
" '_sh': <module 'IPython.core.shadowns' from '/home/ajay/anaconda3/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
" 'exit': <IPython.core.autocall.ZMQExitAutocall at 0xb616bfcc>,\n",
" 'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0xb614c72c>>,\n",
" 'i': 1,\n",
" 'myfirstfunction': <function __main__.myfirstfunction>,\n",
" 'mynewfunction': <function __main__.mynewfunction>,\n",
" 'quit': <IPython.core.autocall.ZMQExitAutocall at 0xb616bfcc>,\n",
" 'x': 24}"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"locals()"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'In': ['',\n",
" '2+3+5',\n",
" '66-3-(-4)',\n",
" '2^3',\n",
" '3^3',\n",
" '44%%3',\n",
" '44%3',\n",
" '43/3',\n",
" '32*3',\n",
" '2**3',\n",
" '32//3',\n",
" 'for i in 1:30\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print %i',\n",
" 'for i in range(1,30):\\n print %(i)',\n",
" 'for i in range(1,30):\\n print % (i)',\n",
" 'for i in range (1,30):\\n print % (i)',\n",
" 'for x in range(0, 30):\\n print % (x)',\n",
" 'for x in range(0, 30):\\n print (x)',\n",
" 'for x in range(0, 30,6):\\n print (x)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'myfirstfunction(20)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n myfirstfunction (x)',\n",
" 'def myfirstfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def mynewfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'mynewfunction(1,3)',\n",
" 'mynewfunction(10,3)',\n",
" 'locals()',\n",
" 'global()',\n",
" 'globals()'],\n",
" 'Out': {1: 10,\n",
" 2: 67,\n",
" 3: 1,\n",
" 4: 0,\n",
" 6: 2,\n",
" 7: 14.333333333333334,\n",
" 8: 96,\n",
" 9: 8,\n",
" 10: 10,\n",
" 33: {...}},\n",
" '_': {...},\n",
" '_1': 10,\n",
" '_10': 10,\n",
" '_2': 67,\n",
" '_3': 1,\n",
" '_33': {...},\n",
" '_4': 0,\n",
" '_6': 2,\n",
" '_7': 14.333333333333334,\n",
" '_8': 96,\n",
" '_9': 8,\n",
" '__': 10,\n",
" '___': 8,\n",
" '__builtin__': <module 'builtins' (built-in)>,\n",
" '__builtins__': <module 'builtins' (built-in)>,\n",
" '__doc__': 'Automatically created module for IPython interactive environment',\n",
" '__loader__': None,\n",
" '__name__': '__main__',\n",
" '__package__': None,\n",
" '__spec__': None,\n",
" '_dh': ['/home/ajay'],\n",
" '_i': 'global()',\n",
" '_i1': '2+3+5',\n",
" '_i10': '32//3',\n",
" '_i11': 'for i in 1:30\\n print i',\n",
" '_i12': 'for i in 1:30:\\n print i',\n",
" '_i13': 'for i in 1:30:\\n print i',\n",
" '_i14': 'for i in range(1,30):\\n print i',\n",
" '_i15': 'for i in range(1,30):\\n print i',\n",
" '_i16': 'for i in range(1,30):\\n print %i',\n",
" '_i17': 'for i in range(1,30):\\n print %(i)',\n",
" '_i18': 'for i in range(1,30):\\n print % (i)',\n",
" '_i19': 'for i in range (1,30):\\n print % (i)',\n",
" '_i2': '66-3-(-4)',\n",
" '_i20': 'for x in range(0, 30):\\n print % (x)',\n",
" '_i21': 'for x in range(0, 30):\\n print (x)',\n",
" '_i22': 'for x in range(0, 30,6):\\n print (x)',\n",
" '_i23': 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" '_i24': 'myfirstfunction(20)',\n",
" '_i25': 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" '_i26': 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" '_i27': 'for x in range(0, 30,6):\\n myfirstfunction (x)',\n",
" '_i28': 'def myfirstfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" '_i29': 'def mynewfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" '_i3': '2^3',\n",
" '_i30': 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" '_i31': 'mynewfunction(1,3)',\n",
" '_i32': 'mynewfunction(10,3)',\n",
" '_i33': 'locals()',\n",
" '_i34': 'global()',\n",
" '_i35': 'globals()',\n",
" '_i4': '3^3',\n",
" '_i5': '44%%3',\n",
" '_i6': '44%3',\n",
" '_i7': '43/3',\n",
" '_i8': '32*3',\n",
" '_i9': '2**3',\n",
" '_ih': ['',\n",
" '2+3+5',\n",
" '66-3-(-4)',\n",
" '2^3',\n",
" '3^3',\n",
" '44%%3',\n",
" '44%3',\n",
" '43/3',\n",
" '32*3',\n",
" '2**3',\n",
" '32//3',\n",
" 'for i in 1:30\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in 1:30:\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print i',\n",
" 'for i in range(1,30):\\n print %i',\n",
" 'for i in range(1,30):\\n print %(i)',\n",
" 'for i in range(1,30):\\n print % (i)',\n",
" 'for i in range (1,30):\\n print % (i)',\n",
" 'for x in range(0, 30):\\n print % (x)',\n",
" 'for x in range(0, 30):\\n print (x)',\n",
" 'for x in range(0, 30,6):\\n print (x)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'myfirstfunction(20)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n print myfirstfunction(x)',\n",
" 'for x in range(0, 30,6):\\n myfirstfunction (x)',\n",
" 'def myfirstfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def mynewfunction(x,y):\\n z=x**3+3*x*y+20*y\\n print(z)',\n",
" 'def myfirstfunction(x):\\n y=x**3+3*x+20\\n print(y)',\n",
" 'mynewfunction(1,3)',\n",
" 'mynewfunction(10,3)',\n",
" 'locals()',\n",
" 'global()',\n",
" 'globals()'],\n",
" '_ii': 'locals()',\n",
" '_iii': 'mynewfunction(10,3)',\n",
" '_oh': {1: 10,\n",
" 2: 67,\n",
" 3: 1,\n",
" 4: 0,\n",
" 6: 2,\n",
" 7: 14.333333333333334,\n",
" 8: 96,\n",
" 9: 8,\n",
" 10: 10,\n",
" 33: {...}},\n",
" '_sh': <module 'IPython.core.shadowns' from '/home/ajay/anaconda3/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
" 'exit': <IPython.core.autocall.ZMQExitAutocall at 0xb616bfcc>,\n",
" 'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0xb614c72c>>,\n",
" 'i': 1,\n",
" 'myfirstfunction': <function __main__.myfirstfunction>,\n",
" 'mynewfunction': <function __main__.mynewfunction>,\n",
" 'quit': <IPython.core.autocall.ZMQExitAutocall at 0xb616bfcc>,\n",
" 'x': 24}"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"globals()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## More Numerical Operations"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import math \n"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"7.38905609893065"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math.exp(2)"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.6931471805599453"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math.log(2)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.30102999566398114"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math.log(2,10)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3.1622776601683795"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math.sqrt(10)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"['__doc__',\n",
" '__file__',\n",
" '__loader__',\n",
" '__name__',\n",
" '__package__',\n",
" '__spec__',\n",
" 'acos',\n",
" 'acosh',\n",
" 'asin',\n",
" 'asinh',\n",
" 'atan',\n",
" 'atan2',\n",
" 'atanh',\n",
" 'ceil',\n",
" 'copysign',\n",
" 'cos',\n",
" 'cosh',\n",
" 'degrees',\n",
" 'e',\n",
" 'erf',\n",
" 'erfc',\n",
" 'exp',\n",
" 'expm1',\n",
" 'fabs',\n",
" 'factorial',\n",
" 'floor',\n",
" 'fmod',\n",
" 'frexp',\n",
" 'fsum',\n",
" 'gamma',\n",
" 'hypot',\n",
" 'isfinite',\n",
" 'isinf',\n",
" 'isnan',\n",
" 'ldexp',\n",
" 'lgamma',\n",
" 'log',\n",
" 'log10',\n",
" 'log1p',\n",
" 'log2',\n",
" 'modf',\n",
" 'pi',\n",
" 'pow',\n",
" 'radians',\n",
" 'sin',\n",
" 'sinh',\n",
" 'sqrt',\n",
" 'tan',\n",
" 'tanh',\n",
" 'trunc']"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dir(math)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"a=[23,45,78,97,89]"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"list"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(a)"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(a)"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"97"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"max(a)"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"23"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"min(a)"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"332"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sum(a)"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"66.400000000000006"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"numpy.mean(a)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"['ALLOW_THREADS',\n",
" 'BUFSIZE',\n",
" 'CLIP',\n",
" 'ComplexWarning',\n",
" 'DataSource',\n",
" 'ERR_CALL',\n",
" 'ERR_DEFAULT',\n",
" 'ERR_IGNORE',\n",
" 'ERR_LOG',\n",
" 'ERR_PRINT',\n",
" 'ERR_RAISE',\n",
" 'ERR_WARN',\n",
" 'FLOATING_POINT_SUPPORT',\n",
" 'FPE_DIVIDEBYZERO',\n",
" 'FPE_INVALID',\n",
" 'FPE_OVERFLOW',\n",
" 'FPE_UNDERFLOW',\n",
" 'False_',\n",
" 'Inf',\n",
" 'Infinity',\n",
" 'MAXDIMS',\n",
" 'MachAr',\n",
" 'ModuleDeprecationWarning',\n",
" 'NAN',\n",
" 'NINF',\n",
" 'NZERO',\n",
" 'NaN',\n",
" 'PINF',\n",
" 'PZERO',\n",
" 'PackageLoader',\n",
" 'RAISE',\n",
" 'RankWarning',\n",
" 'SHIFT_DIVIDEBYZERO',\n",
" 'SHIFT_INVALID',\n",
" 'SHIFT_OVERFLOW',\n",
" 'SHIFT_UNDERFLOW',\n",
" 'ScalarType',\n",
" 'Tester',\n",
" 'True_',\n",
" 'UFUNC_BUFSIZE_DEFAULT',\n",
" 'UFUNC_PYVALS_NAME',\n",
" 'VisibleDeprecationWarning',\n",
" 'WRAP',\n",
" '__NUMPY_SETUP__',\n",
" '__all__',\n",
" '__builtins__',\n",
" '__cached__',\n",
" '__config__',\n",
" '__doc__',\n",
" '__file__',\n",
" '__git_revision__',\n",
" '__loader__',\n",
" '__name__',\n",
" '__package__',\n",
" '__path__',\n",
" '__spec__',\n",
" '__version__',\n",
" '_import_tools',\n",
" '_mat',\n",
" 'abs',\n",
" 'absolute',\n",
" 'absolute_import',\n",
" 'add',\n",
" 'add_docstring',\n",
" 'add_newdoc',\n",
" 'add_newdoc_ufunc',\n",
" 'add_newdocs',\n",
" 'alen',\n",
" 'all',\n",
" 'allclose',\n",
" 'alltrue',\n",
" 'alterdot',\n",
" 'amax',\n",
" 'amin',\n",
" 'angle',\n",
" 'any',\n",
" 'append',\n",
" 'apply_along_axis',\n",
" 'apply_over_axes',\n",
" 'arange',\n",
" 'arccos',\n",
" 'arccosh',\n",
" 'arcsin',\n",
" 'arcsinh',\n",
" 'arctan',\n",
" 'arctan2',\n",
" 'arctanh',\n",
" 'argmax',\n",
" 'argmin',\n",
" 'argpartition',\n",
" 'argsort',\n",
" 'argwhere',\n",
" 'around',\n",
" 'array',\n",
" 'array2string',\n",
" 'array_equal',\n",
" 'array_equiv',\n",
" 'array_repr',\n",
" 'array_split',\n",
" 'array_str',\n",
" 'asanyarray',\n",
" 'asarray',\n",
" 'asarray_chkfinite',\n",
" 'ascontiguousarray',\n",
" 'asfarray',\n",
" 'asfortranarray',\n",
" 'asmatrix',\n",
" 'asscalar',\n",
" 'atleast_1d',\n",
" 'atleast_2d',\n",
" 'atleast_3d',\n",
" 'average',\n",
" 'bartlett',\n",
" 'base_repr',\n",
" 'bench',\n",
" 'binary_repr',\n",
" 'bincount',\n",
" 'bitwise_and',\n",
" 'bitwise_not',\n",
" 'bitwise_or',\n",
" 'bitwise_xor',\n",
" 'blackman',\n",
" 'bmat',\n",
" 'bool',\n",
" 'bool8',\n",
" 'bool_',\n",
" 'broadcast',\n",
" 'broadcast_arrays',\n",
" 'busday_count',\n",
" 'busday_offset',\n",
" 'busdaycalendar',\n",
" 'byte',\n",
" 'byte_bounds',\n",
" 'bytes0',\n",
" 'bytes_',\n",
" 'c_',\n",
" 'can_cast',\n",
" 'cast',\n",
" 'cdouble',\n",
" 'ceil',\n",
" 'cfloat',\n",
" 'char',\n",
" 'character',\n",
" 'chararray',\n",
" 'choose',\n",
" 'clip',\n",
" 'clongdouble',\n",
" 'clongfloat',\n",
" 'column_stack',\n",
" 'common_type',\n",
" 'compare_chararrays',\n",
" 'compat',\n",
" 'complex',\n",
" 'complex128',\n",
" 'complex192',\n",
" 'complex64',\n",
" 'complex_',\n",
" 'complexfloating',\n",
" 'compress',\n",
" 'concatenate',\n",
" 'conj',\n",
" 'conjugate',\n",
" 'convolve',\n",
" 'copy',\n",
" 'copysign',\n",
" 'copyto',\n",
" 'core',\n",
" 'corrcoef',\n",
" 'correlate',\n",
" 'cos',\n",
" 'cosh',\n",
" 'count_nonzero',\n",
" 'cov',\n",
" 'cross',\n",
" 'csingle',\n",
" 'ctypeslib',\n",
" 'cumprod',\n",
" 'cumproduct',\n",
" 'cumsum',\n",
" 'datetime64',\n",
" 'datetime_as_string',\n",
" 'datetime_data',\n",
" 'deg2rad',\n",
" 'degrees',\n",
" 'delete',\n",
" 'deprecate',\n",
" 'deprecate_with_doc',\n",
" 'diag',\n",
" 'diag_indices',\n",
" 'diag_indices_from',\n",
" 'diagflat',\n",
" 'diagonal',\n",
" 'diff',\n",
" 'digitize',\n",
" 'disp',\n",
" 'divide',\n",
" 'division',\n",
" 'dot',\n",
" 'double',\n",
" 'dsplit',\n",
" 'dstack',\n",
" 'dtype',\n",
" 'e',\n",
" 'ediff1d',\n",
" 'einsum',\n",
" 'emath',\n",
" 'empty',\n",
" 'empty_like',\n",
" 'equal',\n",
" 'errstate',\n",
" 'euler_gamma',\n",
" 'exp',\n",
" 'exp2',\n",
" 'expand_dims',\n",
" 'expm1',\n",
" 'extract',\n",
" 'eye',\n",
" 'fabs',\n",
" 'fastCopyAndTranspose',\n",
" 'fft',\n",
" 'fill_diagonal',\n",
" 'find_common_type',\n",
" 'finfo',\n",
" 'fix',\n",
" 'flatiter',\n",
" 'flatnonzero',\n",
" 'flexible',\n",
" 'fliplr',\n",
" 'flipud',\n",
" 'float',\n",
" 'float16',\n",
" 'float32',\n",
" 'float64',\n",
" 'float96',\n",
" 'float_',\n",
" 'floating',\n",
" 'floor',\n",
" 'floor_divide',\n",
" 'fmax',\n",
" 'fmin',\n",
" 'fmod',\n",
" 'format_parser',\n",
" 'frexp',\n",
" 'frombuffer',\n",
" 'fromfile',\n",
" 'fromfunction',\n",
" 'fromiter',\n",
" 'frompyfunc',\n",
" 'fromregex',\n",
" 'fromstring',\n",
" 'full',\n",
" 'full_like',\n",
" 'fv',\n",
" 'generic',\n",
" 'genfromtxt',\n",
" 'get_array_wrap',\n",
" 'get_include',\n",
" 'get_printoptions',\n",
" 'getbufsize',\n",
" 'geterr',\n",
" 'geterrcall',\n",
" 'geterrobj',\n",
" 'gradient',\n",
" 'greater',\n",
" 'greater_equal',\n",
" 'half',\n",
" 'hamming',\n",
" 'hanning',\n",
" 'histogram',\n",
" 'histogram2d',\n",
" 'histogramdd',\n",
" 'hsplit',\n",
" 'hstack',\n",
" 'hypot',\n",
" 'i0',\n",
" 'identity',\n",
" 'iinfo',\n",
" 'imag',\n",
" 'in1d',\n",
" 'index_exp',\n",
" 'indices',\n",
" 'inexact',\n",
" 'inf',\n",
" 'info',\n",
" 'infty',\n",
" 'inner',\n",
" 'insert',\n",
" 'int',\n",
" 'int0',\n",
" 'int16',\n",
" 'int32',\n",
" 'int64',\n",
" 'int8',\n",
" 'int_',\n",
" 'int_asbuffer',\n",
" 'intc',\n",
" 'integer',\n",
" 'interp',\n",
" 'intersect1d',\n",
" 'intp',\n",
" 'invert',\n",
" 'ipmt',\n",
" 'irr',\n",
" 'is_busday',\n",
" 'isclose',\n",
" 'iscomplex',\n",
" 'iscomplexobj',\n",
" 'isfinite',\n",
" 'isfortran',\n",
" 'isinf',\n",
" 'isnan',\n",
" 'isneginf',\n",
" 'isposinf',\n",
" 'isreal',\n",
" 'isrealobj',\n",
" 'isscalar',\n",
" 'issctype',\n",
" 'issubclass_',\n",
" 'issubdtype',\n",
" 'issubsctype',\n",
" 'iterable',\n",
" 'ix_',\n",
" 'kaiser',\n",
" 'kron',\n",
" 'ldexp',\n",
" 'left_shift',\n",
" 'less',\n",
" 'less_equal',\n",
" 'lexsort',\n",
" 'lib',\n",
" 'linalg',\n",
" 'linspace',\n",
" 'little_endian',\n",
" 'load',\n",
" 'loads',\n",
" 'loadtxt',\n",
" 'log',\n",
" 'log10',\n",
" 'log1p',\n",
" 'log2',\n",
" 'logaddexp',\n",
" 'logaddexp2',\n",
" 'logical_and',\n",
" 'logical_not',\n",
" 'logical_or',\n",
" 'logical_xor',\n",
" 'logspace',\n",
" 'long',\n",
" 'longcomplex',\n",
" 'longdouble',\n",
" 'longfloat',\n",
" 'longlong',\n",
" 'lookfor',\n",
" 'ma',\n",
" 'mafromtxt',\n",
" 'mask_indices',\n",
" 'mat',\n",
" 'math',\n",
" 'matrix',\n",
" 'matrixlib',\n",
" 'max',\n",
" 'maximum',\n",
" 'maximum_sctype',\n",
" 'may_share_memory',\n",
" 'mean',\n",
" 'median',\n",
" 'memmap',\n",
" 'meshgrid',\n",
" 'mgrid',\n",
" 'min',\n",
" 'min_scalar_type',\n",
" 'minimum',\n",
" 'mintypecode',\n",
" 'mirr',\n",
" 'mod',\n",
" 'modf',\n",
" 'msort',\n",
" 'multiply',\n",
" 'nan',\n",
" 'nan_to_num',\n",
" 'nanargmax',\n",
" 'nanargmin',\n",
" 'nanmax',\n",
" 'nanmean',\n",
" 'nanmedian',\n",
" 'nanmin',\n",
" 'nanpercentile',\n",
" 'nanstd',\n",
" 'nansum',\n",
" 'nanvar',\n",
" 'nbytes',\n",
" 'ndarray',\n",
" 'ndenumerate',\n",
" 'ndfromtxt',\n",
" 'ndim',\n",
" 'ndindex',\n",
" 'nditer',\n",
" 'negative',\n",
" 'nested_iters',\n",
" 'newaxis',\n",
" 'nextafter',\n",
" 'nonzero',\n",
" 'not_equal',\n",
" 'nper',\n",
" 'npv',\n",
" 'numarray',\n",
" 'number',\n",
" 'obj2sctype',\n",
" 'object',\n",
" 'object0',\n",
" 'object_',\n",
" 'ogrid',\n",
" 'oldnumeric',\n",
" 'ones',\n",
" 'ones_like',\n",
" 'outer',\n",
" 'packbits',\n",
" 'pad',\n",
" 'partition',\n",
" 'percentile',\n",
" 'pi',\n",
" 'piecewise',\n",
" 'pkgload',\n",
" 'place',\n",
" 'pmt',\n",
" 'poly',\n",
" 'poly1d',\n",
" 'polyadd',\n",
" 'polyder',\n",
" 'polydiv',\n",
" 'polyfit',\n",
" 'polyint',\n",
" 'polymul',\n",
" 'polynomial',\n",
" 'polysub',\n",
" 'polyval',\n",
" 'power',\n",
" 'ppmt',\n",
" 'print_function',\n",
" 'prod',\n",
" 'product',\n",
" 'promote_types',\n",
" 'ptp',\n",
" 'put',\n",
" 'putmask',\n",
" 'pv',\n",
" 'r_',\n",
" 'rad2deg',\n",
" 'radians',\n",
" 'random',\n",
" 'rank',\n",
" 'rate',\n",
" 'ravel',\n",
" 'ravel_multi_index',\n",
" 'real',\n",
" 'real_if_close',\n",
" 'rec',\n",
" 'recarray',\n",
" 'recfromcsv',\n",
" 'recfromtxt',\n",
" 'reciprocal',\n",
" 'record',\n",
" 'remainder',\n",
" 'repeat',\n",
" 'require',\n",
" 'reshape',\n",
" 'resize',\n",
" 'restoredot',\n",
" 'result_type',\n",
" 'right_shift',\n",
" 'rint',\n",
" 'roll',\n",
" 'rollaxis',\n",
" 'roots',\n",
" 'rot90',\n",
" 'round',\n",
" 'round_',\n",
" 'row_stack',\n",
" 's_',\n",
" 'safe_eval',\n",
" 'save',\n",
" 'savetxt',\n",
" 'savez',\n",
" 'savez_compressed',\n",
" 'sctype2char',\n",
" 'sctypeDict',\n",
" 'sctypeNA',\n",
" 'sctypes',\n",
" 'searchsorted',\n",
" 'select',\n",
" 'set_numeric_ops',\n",
" 'set_printoptions',\n",
" 'set_string_function',\n",
" 'setbufsize',\n",
" 'setdiff1d',\n",
" 'seterr',\n",
" 'seterrcall',\n",
" 'seterrobj',\n",
" 'setxor1d',\n",
" 'shape',\n",
" 'short',\n",
" 'show_config',\n",
" 'sign',\n",
" 'signbit',\n",
" 'signedinteger',\n",
" 'sin',\n",
" 'sinc',\n",
" 'single',\n",
" 'singlecomplex',\n",
" 'sinh',\n",
" 'size',\n",
" 'sometrue',\n",
" 'sort',\n",
" 'sort_complex',\n",
" 'source',\n",
" 'spacing',\n",
" 'split',\n",
" 'sqrt',\n",
" 'square',\n",
" 'squeeze',\n",
" 'std',\n",
" 'str',\n",
" 'str0',\n",
" 'str_',\n",
" 'string_',\n",
" 'subtract',\n",
" 'sum',\n",
" 'swapaxes',\n",
" 'sys',\n",
" 'take',\n",
" 'tan',\n",
" 'tanh',\n",
" 'tensordot',\n",
" 'test',\n",
" 'testing',\n",
" 'tile',\n",
" 'timedelta64',\n",
" 'trace',\n",
" 'transpose',\n",
" 'trapz',\n",
" 'tri',\n",
" 'tril',\n",
" 'tril_indices',\n",
" 'tril_indices_from',\n",
" 'trim_zeros',\n",
" 'triu',\n",
" 'triu_indices',\n",
" 'triu_indices_from',\n",
" 'true_divide',\n",
" 'trunc',\n",
" 'typeDict',\n",
" 'typeNA',\n",
" 'typecodes',\n",
" 'typename',\n",
" 'ubyte',\n",
" 'ufunc',\n",
" 'uint',\n",
" 'uint0',\n",
" 'uint16',\n",
" 'uint32',\n",
" 'uint64',\n",
" 'uint8',\n",
" 'uintc',\n",
" 'uintp',\n",
" 'ulonglong',\n",
" 'unicode',\n",
" 'unicode_',\n",
" 'union1d',\n",
" 'unique',\n",
" 'unpackbits',\n",
" 'unravel_index',\n",
" 'unsignedinteger',\n",
" 'unwrap',\n",
" 'ushort',\n",
" 'vander',\n",
" 'var',\n",
" 'vdot',\n",
" 'vectorize',\n",
" 'version',\n",
" 'void',\n",
" 'void0',\n",
" 'vsplit',\n",
" 'vstack',\n",
" 'warnings',\n",
" 'where',\n",
" 'who',\n",
" 'zeros',\n",
" 'zeros_like']"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dir(numpy)"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"28.011426240018555"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"numpy.std(a)"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"784.63999999999999"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"numpy.var(a)"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#Example of Help\n",
"numpy.random?"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n"
]
}
],
"source": [
"from random import randint,randrange\n",
"print(randint(0,9))"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
" randrange(10)"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8\n",
"3\n",
"7\n",
"8\n",
"5\n"
]
}
],
"source": [
"for x in range(0,5):\n",
" print(randrange(10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment