""" This is an example that uses the recommended style for programs written in Python for Software Development & Problem Solving I. This file comment should provide a general description of the program. General considerations of style: - Use fully-spelled out names for functions, variables, and parameters. - The standard for Python is words_with_underscores. Do not use alternatingCamelCase. - Write a file comment like this one. - Every function should have a docstring. - If the function declares parameters, they should be documented in the docstring. - If the function returns a value, it should be documented in the docstring. - Use inline comments only when necessary. author: GCCIS Faculty """ # imports are at the top (but below the file comment). import math import random # global variables are declared before any functions DAYS_IN_YEAR = 365 DAYS_IN_LEAP_YEAR = DAYS_IN_YEAR + 1 SHORTEST_MONTH = 28 def example_function(): """ A docstring should be provided to explain the purpose of each function. """ print("An example function!") def exponent(base, power): """ This function raises the base value to the specified power and returns the result. Note that the variable names are fully-spelled-out words (not single characters or abbreviations). Parameters: base: the base of the exponent (a number) power: the power to which the base should be raised (a number) Returns: The result of raising the base to the power (a number). """ result = math.pow(base, power) # inline comments return result # used as needed def main(): """ By stylistic convention, the only code that should appear outside of a function in the programs that you write is the call to main and the declaration of any global variables. The main function should include any code that you would like to execute when the module is run. """ example_function() # prompt the user for the base and power base = float(input("Enter base: ")) power = float(input("Enter exponent: ")) # calculate and print the result result = exponent(base, power) print(base, "^", power, " = ", result, sep="") print("Goodbye!") ''' Used to make sure that, if this program is imported into another module, the main method will not be executed. ''' if __name__ == "__main__": main()