Lab 3, Part 1: print, return, and None

Summary

Here is the worksheet as a google doc Open the document, then File -> Make a Copy. Then you can edit your copy with your answers.

Examine the following functions. Which are fruitful and which are None functions?

def hello(x):
    print('--', x, '--')

def square(x):
    return x * x

def showSquare(num):
    print('The argument of square is ' + str(num))
    return square(num)

Predict the outcome of the invocations below:

>>> hello('froggy')

>>> print(hello('bunny'))
>>> square(3) + square(4)
>>> square(square(3))
>>> showSquare(5)
>>> showSquare(3) + showSquare(4)
>>> hello('frog') + hello('toad')

Table of Contents