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

print('<pre>')                          #to produce better display on the web 

name   = 'Sam'
number = 123

print("===== if =====")
if name=='Sam':
    print("Your name is 'Sam'")
    print("That is a good name")
print ()

print("===== if/else =====")
if name=='Sam':
    print('Your name is Sam')
else:
    print('Your name is not Sam')
print ()

print("===== if/elif/else =====")
if name=='Sam':
    print('Your name is Sam')
elif name=='sam':
    print('Your name sam')
else:
    print('Your name is not Sam or sam') 
print ()
    
print("===== using and =====")
if name=='Sam' and number==123 :
    print('Your name is', name, 'and the number is:', number)
print ()

print("===== using or =====")
if name=='Sam' or number==123 :
    print('Your name is either', name, 'or the number is:', number)
print ()

print("===== Nested if =====")
if name=='Sam':    
    if number==123:
        print('Using nested if(s). Your name is', name, 'and the number is', 123)
print ()
        
print("===== Precedence and/or =====")
if number==123 or number==124 and name=='Sam':
    print("Precedence is: 'and' before 'or'")
        
if (number==123 or number==124) and name=='Sam':
    print("With parenthesis you can execute 'or' before 'and'")