Home / Expert Answers / Computer Science / asap-python-write-a-generator-function-mygen-that-uses-a-sequence-of-numbers-1-2-10-to-gene-pa988

(Solved): ASAP (PYTHON) Write a generator function myGen() that uses a sequence of numbers (1,2, , 10) to gene ...



ASAP (PYTHON)

Write a generator function myGen() that uses a sequence of numbers (1,2, , 10) to generate a stream of 10 output numbers foll
Write a generator function myGen() that uses a sequence of numbers (1,2, , 10) to generate a stream of 10 output numbers following these two conditions - For even numbers, myGen() will generate the power of 2 for the number, Example: if num = 2, then myGen() will print 4 - For odd numbers, myGon() wili generate the square root of the number. Example if num \( =4 \), then myGen() will print 2 Call your generator and print all output numbers. The printed oufput by my Gen() function should be as following: 10 4 \( 1.7320508075688772 \) 16 \( 2.23600797749079 \) 36 \( 2.6457513110645007 \) 64 30 100 [You can import math module and use the butan inothode if needed (e g., math.sqrto function) )


We have an Answer from Expert

View Expert Answer

Expert Answer


import math def myGen(): for number in r
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe