''' Purpose: Exercise module olio ''' import olio # I WANT TO USE THE MODULE OLIO WHICH HAS MY FUNCTION DEFINITIONS! # This file that uses functions from the olio module # won't be able to use the functions from olio unless I import it. # uncomment below lines to test voting_age() # These are function calls for olio.voting_age()! # We store them in variables x and y since the function returns 18 and the variables store whatever the # function hands back (18) so x and y are assigned the value of the function return (18). # You can't give arguments if the function definition doesn't have any parameters to provide arguments for! # Arguments are the values that are passed into our parameters so that the function can start up! # Using Functions From Module # module.function_name( parameters ) # x = olio.voting_age(12) x = olio.voting_age() y = olio.voting_age() z = x + y print( x ) print( y ) print( z ) print() # uncomment below lines to test has_blanks() line1 = input( 'Enter text: ' ) line2 = input( 'Enter text: ' ) # b1 and b2 are assigned the value of what the function returns (True/False!) b1 = olio.has_blanks( line1 ) b2 = olio.has_blanks( line2 ) # So.. RETURN IS NOT THE SAME THING AS PRINT. This is IMPORTANT! # print() prints something to the console and return hands something back to the code! # Just because you return something doesn't mean it's going to get printed! # We usually store the return value in a variable (b1 = olio.has_blanks(line1)) where the function call # that returns something is stored in b1 (the return value True/False is stored in b1) # and THENNN we print b1 and b2 that STORE the return value! # SO RETURN IS NOT THE SAME THING AS PRINT. # Usually the function figures something out and then we can display it if we want. We don't always wanna # print something a function evaluates. More examples on this later! # These notes are posteddd but go off ig print( b1 ) print( b2 ) print() # uncomment below lines to test great_seal() olio.great_seal() olio.great_seal() # So we didn't store these function calls in variables! # Why? # Because the function just prints out what we want to see anyways it just EXECUTES the code but doesn't # hand back anything so we don't want to store it in a variable because then the variable would be assigned to None! # The function great_seal() returns None by default. r1 = olio.great_seal() r2 = olio.great_seal() # SO IT DOES WHAT'S IN THE FUNCTION aka print butttt the value it returns when we set it to r1 and r2 # is None so that's why r1 and r2 are None. # ALL FUNCTIONS HAVE A RETURN VALUE (explicit return value or None) # voting_age() returned 18 so 18 is the RETURN VALUE but great_seal() returns None because we didn't do a return statement. # The parameters are the things inside the () in a function definition. # The arguments are the values we pass in for the parameters in the function call. print( r1 ) print( r2 ) print() # uncomment below lines to test a_ing() reply1 = input( 'Enter integer: ' ) reply2 = input( 'Enter integer: ' ) reply3 = input( 'Enter integer: ' ) nbr1 = int( reply1 ) nbr2 = int( reply2 ) nbr3 = int( reply3 ) olio.a_ing( nbr1 ) print() olio.a_ing( nbr2 ) print() olio.a_ing( nbr3 ) print()