#!/usr/bin/env python3
#=====================================================================================
# Python dictionaries 
#=====================================================================================
print("Content-Type: text/html \n")     #http header with newline char (required for web)

print('''
    <html>
    <body>
    <h1>Python Dictionaries</h1>
''')

stuff1 = {}
stuff2 = {'work':'weekday', 'fun':'weekend'}   
stuff3 = {'first':'Sam', 'last':'Sultan', 'gender':'M', 1:'one'}                #keys can be of different data types

print('Printing empty stuff1 dictionary:', stuff1, '<br>')
print('<br>')

print('Printing stuff2 dictionary.......... :', stuff2, '<br>')
print('Printing number of elements in stuff2:', len(stuff2), '<br>')            #an element is a name/value pair
print('<br>')

print('Printing the entire stuff3 dictionary..:', stuff3, '<br>')
print("Printing the content of element 'first':", stuff3['first'], '<br>')
print("Printing the content of element 1 .....:", stuff3[1], '<br>')
stuff3['first'] = 'Samuel'                                                      #change element
stuff3['age']   = 50                                                            #add new element
stuff3[2]       = 'two'                                                         #add new element
del stuff3[1]                                                                   #delete element
print('After add, change and delete .........:', stuff3, '<br>')
print('<br>')

print('''
    </body>
    </html>
''')



#=== 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
#=================================================================================