Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanBaird authored May 28, 2022
1 parent 980464d commit 4039386
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions You're_a_square!_kyu7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# # A function that works out if any given number is a square number
# Various previous attempts
# Import math
# If statement that ensures we're only working with positive numbers
# Variable that temporarily stores the square root of n
# Forces the square root to be an int and times is by itself to work out if n is a square number

import math


def is_square(n):
# squares = []
# ranges = range(0,999)
# for number in ranges:
# squares += ([number * number])
# print(n)
# if n in squares:
# return True
# elif n < 0:
# return False
# else:
# return False

# if n < 0:
# return False
# if n >= 0:
# root = math.sqrt(n)
# root_type = type(root)
# print(root)
# print(root_type)
# if root_type is int:
# return True
# else:
# return False

if n < 0:
return False
if n >= 0:
root = math.sqrt(n)
if int(root) * int(root) == n:
return True
else:
return False

0 comments on commit 4039386

Please sign in to comment.