Chapter 16: Controlling Complexity

Example 16.1, page no. 705

In [1]:
def cube(i):
    return i*i*i
def beep():
    print "\a"

Example mainprog.c, page no. 705

In [3]:
print "The cube of 10 is ", cube(10)
input_int = int(raw_input("Input Integer: "))
if input_int < 1:
    beep()
    print "Input is Invalid"
else:
    print "The cube of %d is %d" %(input_int, cube(input_int))
The cube of 10 is  1000
Input Integer: 0

Input is Invalid

Example make.c, page no. 709

In [ ]:
def cube(i):
    return i*i*i
def beep():
    print "I am going to beep!"
    print "\a"