#Importing math library to check if a number is a perfect square
import math
def perfectSquare(x):
root = math.sqrt(x)
if int(root + 0.5) ** 2 == x:
return 1
else:
return 0
uniqueCustomerId = [36, 16, 54, 81, 48, 49]
count = 0
print("Input")
print("Unique customer id numbered from 0 to n-1.")
print(uniqueCustomerId)
print("Total number of customers are: "+str(len(uniqueCustomerId)) )
for uniqueId in uniqueCustomerId:
if perfectSquare(uniqueId) == 1:
count += 1
print("Output")
print(count)
Comments
Leave a comment