Skip to content

Instantly share code, notes, and snippets.

@roman-on
Created April 21, 2020 00:16
Show Gist options
  • Save roman-on/f56af547f7aa0c0f2f68084db2c685ca to your computer and use it in GitHub Desktop.
Save roman-on/f56af547f7aa0c0f2f68084db2c685ca to your computer and use it in GitHub Desktop.
"""
The function receives two integers, start and stop (suppose it exists: start <= stop).
The function returns a list where all the number squares are between start and stop (inclusive).
Instructions
Use the while loop only.
>>> squared_numbers(4, 8)
[16, 25, 36, 49, 64]
>>> squared_numbers(-3, 3)
[9, 4, 1, 0, 1, 4, 9]
"""
def squared_numbers(start, stop):
list_of_squares = []
while start <= stop:
list_of_squares.append(start **2)
start += 1
print (list_of_squares)
def main():
squared_numbers(start, stop)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment