I want this program to output x2/y, for y from 1 to 1000 and x from 1 to 1000.
I tried this code:
y = range(0, 1000)
x = range(0, 1000)
stuff = int(x ** 2 / y)
print stuff
But there is an error:
Traceback (most recent call last):
File "testingsci.py", line 3, in <module>
stuff = int(x ** 2 / y)
TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'
How can I do this properly?
As a list comprehension:
print [(x ** 2)/y for x in xrange(1, 1001) for y in xrange(1, 1001)]