Back to www.deitel.com 
1 # Fig. 35.5: fig35_05.py 
2 # Program to illustrate basic data types, control statements and 
3 # functions. 
4 
5 def greatestCommonDivisor( x, y ): 
6 gcd = min( x, y ) 
7 
8 while gcd >= 1: 
9 
10 if ( x % gcd ) == ( y % gcd ) == 0: 
11 return gcd 
12 else: 
13 gcd = 1 
14 
15 def determineColor( color ): 
16 
17 if color == "green": 
18 print "You entered green!" 
19 elif color == "purple": 
20 print "You entered purple!" 
21 else: 
22 print "You did not enter green or purple." 
23 
24 number1 = int( raw_input( "Enter a positive integer: " ) ) 
25 number2 = int( raw_input( "Enter a positive integer: " ) ) 
26 
27 print "The greatest common divisor is", \ 
28 greatestCommonDivisor( number1, number2 ) 
29 
30 for entry in range( 5 ): 
31 colorChoice = raw_input( "\nEnter your favorite color: " ) 
32 determineColor( colorChoice ) 
Enter a positive integer: 2
Enter a positive integer: 30
The greatest common divisor is 2
Enter your favorite color: yellow
You did not enter green or purple.
Enter your favorite color: green
You entered green!
Enter your favorite color: black
You did not enter green or purple.
Enter your favorite color: purple
You entered purple!
Enter your favorite color: red
You did not enter green or purple.
