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