I'm failing the private test cases and want some help. Here is the question and my code.
Topic 5: Question 9 Create a function that takes in a positive number and return 2 integers such that the number is between the squares of the 2 integers. It returns the same integer twice if the number is a square of an integer.
def sqApprox(num):
i = 0
import math
minsq = None
maxsq = None
while i <= math.ceil(num):
if i*i == num:
return (i,i)
if i*i<=num and i >minsq:
minsq = i
if i*i>=num and i>maxsq:
maxsq = i
i +=1
return (minsq, maxsq)
Aucun commentaire:
Enregistrer un commentaire