# ch03_notes.py
# Chapter 3 notes taken from Automate the Boring Stuff with Python (2015).pdf
# Created by Davidzz on 7/20/2016

# Functions:
# no parameters:
# define:
def hello():
    print('Howdy!')
    print('Howdy!!!')
    print('Hello there.')
# call:
hello()
# with parameters:
# define:
def hello(name):
    print('Hello ' + name + '!')
# call:
hello('David')
hello('Belinda')

# returns in functions
import random
def getRandomIntBetweenZeroAnd(num):
    gen = random.randint(0, num)
    return gen
for i in range(5):
    string = str(getRandomIntBetweenZeroAnd(9))
    print(string)

# null == None (N capitalized)

# printing to console
print('Pyt', end='')
print('hon')

print('Hello', 'world!')

print('a', 'a', 'a', 'a', sep = 'A')

# global Statement
def a():
    global num
    char = 'aaaaa'
char = 'bbbbb'
print(char)

# Exceptions
def spam(divideBy):
    try:
        return 42 / divideBy
    except ZeroDivisionError:
        print('Error: Invalid argument.')
print(spam(2))
print(spam(12))
print(spam(0))
print(spam(1))

