#!/usr/bin/env python3
#=====================================================================================
# 1 dimensional numpy array
#=====================================================================================
import numpy 

print("Content-Type: text/html \n")                 #http header with newline char (required for web)


pyArray = [1,2,-3,4,0,5,6.0,11,12.50,-14,15]
npArray = numpy.array(pyArray)

print("Python list: ", pyArray) 
print("Numpy array: ", npArray) 
print() 
print("Datatype...: ", npArray.dtype)
print("Dimension..: ", npArray.ndim)
print("Size.......: ", npArray.size)
print("Shape......: ", npArray.shape)

print()
print("Before any change: ", '      ', npArray)

npArray[5] = 55.5
print("Changed element 5..: ", npArray[5],  npArray)

npArray = numpy.append(npArray, 99)
print("Added new element..: ", npArray[11], npArray)

npArray = numpy.delete(npArray, 3)
print("Delete 3rd element.: ", '    ', npArray)

npSlice1 = npArray[5:10]
print("Taking a slice 5-10: ", '    ', npSlice1)

print()
print("----------ANALYTICS--------------")
print("Count..: ", npArray.size)
print("Sum....: ", numpy.sum(npArray))
print("Average: ", numpy.average(npArray))
print("Median.: ", numpy.median(npArray))
print("Min....: ", numpy.min(npArray))
print("Max....: ", numpy.max(npArray))
print("Range..: ", numpy.ptp(npArray))          #range function
print("Std Dev: ", numpy.std(npArray))




#=== link to see the python code =================================================
import os, sys
sys.path.insert(0,'/home/s/sultans/web/python/demo')
import zCode                          #import func to display the Python code
filename = os.path.abspath(__file__)  #get absolute file name 
zCode.display(filename)               #call it
#=================================================================================