# Structure declaration
from ctypes import *
class person (Structure) :
_fields_ = [("name", c_wchar_p), ("address", c_wchar_p), ("city_state_zip", c_wchar_p), ("age", c_int), ("height", c_float)]
# Function declaration
def lookup (name) :
lists = ['John', 'Jim', 'Jane', 'Clyde']
result = 0
for index in range (0, 4) :
if (lists[index] == name) :
result = 1
break
return result
# Calculation and result
name = 'Jane'
if (lookup (name)) :
print ('%s is in the list\n' % name)
else :
print ('%s is not in the list\n' % name)
# Declaration and result
aList = [45, 89, 123]
aList.insert(1, 53)
print 'Final List : ', aList
# Class declaration
class Node:
def __init__(self, val):
self.l_child = None
self.r_child = None
self.data = val
def binary_insert(root, node):
if root is None:
root = node
else:
if root.data > node.data:
if root.l_child == None:
root.l_child = node
else:
binary_insert(root.l_child, node)
else:
if root.r_child == None:
root.r_child = node
else:
binary_insert(root.r_child, node)
def in_order_print(root):
if not root:
return
in_order_print(root.l_child)
print root.data
in_order_print(root.r_child)
r = Node('Lemon')
binary_insert(r, Node('Plum'))
binary_insert(r, Node('Apple'))
binary_insert(r, Node('Orange'))
binary_insert(r, Node('Pear'))
binary_insert(r, Node('Grape'))
# Result
print "List of words in ASCII order:"
in_order_print(r)