How can I golf this code to count all perfect squares below 100?
For the exact question posed: since we know that 1 is a perfect square and all integers between that and the maximal one (here 9) will be included we can simply find that maximal one:



print((100-1)**.5//1)


(//1 performing integer division by one to remove any fractional part may be replaced with /1 prior to Python 3.)

with both endpoints (an inclusive start and exclusive stop equivalent to a range) this could be extended to a function (negative inputs catered for with max):

f=lambda start, stop:print(max(0,stop-1)**.5//1-max(0,start)**.5//1)