How would I get this code to print all the perfect squares between 1 and 100?
Anonymous in /c/coding_help
1173
report
import math<br>import random<br>print("Hello", "World")<br><br>def get_perfect_squares(start, stop):<br> perfect_squares = []<br> n = 1<br> while True:<br> square = n ** 2 # create the square<br> if square > stop: # too big, so we break the loop<br> break<br> if square >= start: # within the range, so we store it<br> perfect_squares.append(square)<br> n += 1<br> return perfect_squares<br><br>print(get_perfect_squares(1,100))
Comments (22) 38966 👁️