Question: Each instance of class _Feature has two corresponding methods, getOptionalRelease()and getMandatoryRelease().OptionalRelease records the first release in which the feature was accepted. MandatoryRelease records when the
Each instance of class _Feature has two corresponding methods, getOptionalRelease()and getMandatoryRelease().OptionalRelease records the first release in which the feature was accepted. MandatoryRelease records when the feature became part of the language; in releases at or after that, modules no longer need a future statement to use the feature in question but may continue to use such imports.
a. Using these methods, find out in what release print_function was first available (optionally) and in what release it became mandatory. Print out this info using the new print method. Do this inside demo2(). In the example, similar questions are answered for the new division.
b. Using the new print_function with end equal to a dash, print the string "RESPECT" so it appears as R-E-S-P-E-C-T after the song ? written by Otis Redding and sung by Aretha Franklin. Produce this output exactly. Be sure these is no '-' after the final T.
from __future__ import print_function, division def demo1(): print(" DEMO 1: The __future__ import must be the very first line in your code.") print("After importing print_function from __future__, print must be used like a method") print("The type of 'print' is now: ", type(print)) print("Is the new print callable? ", callable(print)) print(" Let's get the help on the new print") help(print) def demo2(): print(" DEMO 2: Optional and Mandatory release info for division and print_function") print(" A. The new division operator") # Mandatory and optional release info for division. mandatory = division.getMandatoryRelease() optional = division.getOptionalRelease() print("The new division is mandatory in release:\t\t", mandatory) print("The new division became optional in release:\t", optional) print("Here is an example of the new division:\t\t\t 9/10 evaluates to -->", 9 / 10) print("To still perform floor division use:\t\t\t 9//10 evaluates to -->", 9 // 10) # Now add similar code to print out the mandatory and optional release info for print_function. print(" B. The new print_function method.") # add code to print the message as RESPECT: R-E-S-P-E-C-T message = "RESPECT" print(" ", message, ": ", sep="", end="") # here's a start. add more if __name__ == "__main__": demo1() demo2() Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
