Click here to view code image
1: pi@raspberrypi ~ $ cat /home/pi/py3prog/script1501.py
2: # script1501.py - Display Bird immutable data via Accessors
3: # Written by Blum and Bresnahan
4: #
5: ############ Import Modules ##################
6: #
7: # Birds object file
8: from birds import Bird
9: #
10: # Barn Swallow object file
11: from barnswallow import BarnSwallow
12: #
13: # South Africa Cliff Swallow object file
14: from sacliffswallow import SouthAfricaCliffSwallow
15: #
16: def main ():
17: ###### Create Variables & Object Instances ###
18: #
19: sex='unknown' #Male, female, or unknown
20: flock_size='0'
21: #
22: bird=Bird(sex)
23: barn_swallow=BarnSwallow(sex,flock_size)
24: sa_cliff_swallow=SouthAfricaCliffSwallow(sex,flock_size)
25: #
26: ########## Show Bird Characteristics ########
27: #
28: print("A bird has",end=' ')
29: if bird.get_feathers() == 'yes':
30: print("feathers,", end=' ')
31: print("bones that are", bird.get_bones(), end=' ')
32: print("and", bird.get_eggs(), "eggs.")
33: #
34: ###### Show Barn Swallow Characteristics #####
35: #
36: print()
37: print("A barn swallow is a bird that", end=' ')
38: if barn_swallow.get_migratory() == 'yes':
39: print("is migratory.")
40: else:
41: print("is not migratory.")
42: #
43: ######## Show Cliff Swallow Characteristics ######
44: #
45: print()
46: print("A cliff swallow is a bird that", end=' ')
47: if sa_cliff_swallow.get_migratory() == 'yes':
48: print("is migratory.")
49: else:
50: print("is not migratory.")
51: #########################################################
52: #
53: ########## Call the main function #######################
54: main()
In the script, the object module files are imported before the start of the main function declaration on
lines 7 through 14. The variables sex and flock_size are to be used as arguments and thus are