migrate to git.charlotte.sh
This commit is contained in:
commit
fbd588721e
412 changed files with 13750 additions and 0 deletions
18
python-csi160/week06/week6practiceproblems/part3.py
Normal file
18
python-csi160/week06/week6practiceproblems/part3.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
def all_squares(n):
|
||||
"""Returns a list that contains all the squares of positive integers
|
||||
where the square is less than or equal to N, in ascending order.
|
||||
|
||||
:param n: (int) Upper bound
|
||||
:return: (list) List of squares
|
||||
"""
|
||||
squares = []
|
||||
i = 1
|
||||
while i * i <= n:
|
||||
squares.append(i * i)
|
||||
i += 1
|
||||
return squares
|
||||
|
||||
|
||||
# Leave this part for easily testing your function
|
||||
print('all_squares(50) returns:', all_squares(50))
|
||||
print('all_squares(9) returns:', all_squares(9))
|
Loading…
Add table
Add a link
Reference in a new issue