If someone wants get my answer notebook you can find here, it is based on homework starter notebook:
def square_root_generator(limit):
n = 1
while n <= limit:
yield n**0.5
n += 1
# Example usage:
limit = 5
generator = square_root_generator(limit)
total = 0
for sqrt_value in generator:
# print(sqrt_value)
total += sqrt_value
print(total)
8.382332347441762
def square_root_generator(limit):
n = 1
while n <= limit:
yield n**0.5
n += 1
# Example usage:
limit = 13
generator = square_root_generator(limit)
for sqrt_value in generator:
print(sqrt_value)
1.0 1.4142135623730951 1.7320508075688772 2.0 2.23606797749979 2.449489742783178 2.6457513110645907 2.8284271247461903 3.0 3.1622776601683795 3.3166247903554 3.4641016151377544 3.605551275463989