11.10. Exercises

11-1. Arguments. Compare the following three functions:

								def countToFour1():
    for eachNum in range(5):
        print eachNum,

def countToFour2(n):
    for eachNum in range(n, 5):
        print eachNum,

def countToFour3(n=1):
    for eachNum in range(n, 5):
        print eachNum,

What do you think will happen as far as output from the program, given the following input values? Enter the output into Table 11.1 below. Write in “ERROR” if you think one will occur with the given input or “ NONE” if there is no output.

Table 11.2. Output chart for Problem 11-1
InputcountToFour1countToFour2countToFour3
2   
4   
5   
(nothing)   

11-2. Functions. Combine your solutions for Exercise 5-2. such that you create a combination function which takes the same pair of numbers and returns ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.