Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

20: def main (): #Mainline
21: ###### Create Variables & Object Instances ###
22: #
23: flock_size='0' #Number of birds sighted
24: sex='unknown' #Male, female, or unknown
25: species='' #Barn or Cliff Swallow Object
26: #
27: barn_swallow=BarnSwallow(sex,flock_size)
28: sa_cliff_swallow=SouthAfricaCliffSwallow(sex,flock_size)
29: #
30: ###### Instructions for Script User #########
31: print()
32: print("The following characteristics are listed")
33: print("in order to help you determine what swallow")
34: print("you have sighted.")
35: print()
36: #
37: ###### Show Barn Swallow Characteristics #####
38: #
39: print("A barn swallow is a bird that", end=' ')
40: if barn_swallow.get_migratory() == 'yes':
41: print("is migratory.")
42: else:
43: print("is not migratory.")
44: #
45: ######## Show Cliff Swallow Characteristics ######
46: #
47: print("A cliff swallow is a bird that", end=' ')
48: if sa_cliff_swallow.get_migratory() == 'yes':
49: print("is migratory.")
50: else:
51: print("is not migratory.")
52: #
53: ######## Obtain Swallow Sighted #################
54: print()
55: print("Which did you see?")
56: print("European/Barn Swallow - 1")
57: print("African Cliff Swallow - 2")
58: species = input("Type number & press Enter: ")
59: print()
60: #
61: ######## Obtain Flock Size #################
62: #
63: flock_size=int(input("Approximately, how many did you see? "))
64: #
65: ###### Mutate Sighted Birds' Flock Size ####
66: #
67: if species == '1':
68: barn_swallow.set_flock_size(flock_size)
69: else:
70: sa_cliff_swallow.set_flock_size(flock_size)
71: #
72: ###### Display Sighting Data ################
73: print()
74: print("Thank you.")
75: print("The following data will be forwarded to")
76: print("the Great Backyard Bird Count.")
77: print("www.birdsource.org/gbbc")
78: #
79: print()
80: print("Sighting on \t", datetime.date.today())

Free download pdf