Question: Function Description Complete the pow_gen as either a function or class in the editor below. pow_gen has the following parameter(s): exp: an integer Constraints
Function Description Complete the pow_gen as either a function or class in the editor below. pow_gen has the following parameter(s): exp: an integer Constraints The maximum value of exp is 20. The maximun value of base is 100. base can be an integer or a string. Input Format For Custom Testing Sample Case 0 Sample Input For Custom Testing STDIN 2 3 3 4 5 Function 9 16 25 exponenent = 2 number of test cases n test case 1, base = 3 test case 2, base = 4 test case 3, base = 5 Sample Output = 3 Generator is stopped Explanation The exponent is 2. 3**2, 4**2, and 5**2 equal 9, 16, and 25. The last line comes from the main() as a result of the generator being stopped safely. Sample Case 1 Language: Python 3 O Environment 1 import os 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 import random def main(path="/dev/stdout") -> None: int(input()) exp = result_str = "" try: Autocomplete Ready with pow gen (exp) as gen: n = int(input()) for in range(n): ibase = input() result_str += str(gen.send(ibase)) + ' ' except ValueError as ve: result_str += str(ve) + ' ' random_int = random.randint (2,100) try: result_str += str(gen.send(random_int)) + except StopIteration as si: result_str += "Generator is stopped " with open (path, "w") as fptr: fptr.write(result_str) Test Results if __name__ == "__main__": path "/dev/stdout" if "OUTPUT_PATH" in os.environ.keys(): path = os.environ["OUTPUT_PATH"] main (path=path) Custom Input www. Run Code Run Tests G Li
Step by Step Solution
There are 3 Steps involved in it
The image you have provided contains a programming challenge description and sample code in Pyt... View full answer
Get step-by-step solutions from verified subject matter experts
