#!/usr/bin/python3
###################################################################################
# print type of variables
###################################################################################
print("Content-Type: text/html \n")     #http header with newline char (required for the web)
 
print('<pre>')                          #to produce better display on the web 
print()

var = "" 
if not var :                                        #var is empty
    print("Variable is empty") 

var = "     "                                       
if var.isspace() :                                  #spaces, tabs and even newlines
    print("Variable is whitespace")

var = "HelloWorld"                                  
if var.isalpha() :                                  #must not have space
    print(var, "is alphabetic") 

var = 123456
print("The type of ", var, "is", type(var))
var = 123456.789
print("The type of ", var, "is", type(var))
var = "SamSultan"
print("The type of ", var, "is", type(var))
var = [1,2,3,4,5,6]
print("The type of ", var, "is", type(var))
var = {1:'a', 2:'b', 3:'c'}
print("The type of ", var, "is", type(var))

if type(var) is dict :                              #You can test for: int,float,str,list,dict
    print("True it is a dictionary")
    
var = "1234"
try:
    int(var)                                        #attempt to convert string to integer
    print(var, "is integer")
except:
    print(var, "is not integer")

var = "1234.45"
try:
    float(var)                                      #attempt to convert string to float
    print(var, "is decimal")
except:
    print(var, "is not decimal")