''' Purpose: develop programmer-defined functions ''' # function voting_age(): returns how old you need to be to vote; i.e. the # integer 18. def voting_age(): result = 18 return result # def voting_age(): # return 18 # Also works ^ # function has_blanks( s ): returns a whether s contains at least one blank # character; i.e., returns True if s contains a blank, and returns # False otherwise. def has_blanks( s ): # This function has a single parameter s # print( 's=', s ) if ( ' ' in s ): return True # result = True else: return False # result = False # return None # Another way: # def has_blanks( s ): # count_blanks = s.count(' ') # if (count_blanks > 0): # return True # else: # return False # function great_seal( ): prints the string 'E Pluribus Unum' def great_seal(): print( 'E Pluribus Unum' ) # function a_ing( n ) prints n lines of output. The first line prints a # single 'a', the second line prints 'aa', the third line prints 'aaa', # and so on. def a_ing( n ): # n is the parameter and we print n lines of output with n a's per line for num_of_as in range(1, n+1): output = 'a' * num_of_as # repeated string concatenation print( output )