Title: Print 1-1000 of these 1000 numbers on the screen, do not use circular statements/conditional statements, do not use?: operator. Not allowed in the source code to enumerate the output statement method silly dozen, such as 1000 print statements do not, no longer repeat other silly dozen behavior, we can understand the spirit. Answer:
Import Syssys.setrecursionlimit (1005) def PR (n): Print ' %d ' % n # t = Int (1/(n-1000)) if n <: PR (n+1) # return None # return NonePR (1)
On the Internet, we found that Python's default recursion depth is very limited, probably more than 900, and when the recursion depth exceeds this value, an exception is thrown. The solution is to manually set the recursive call depth in the following way:
Import sys Sys.setrecursionlimit (# For example here set to 1 million
Python_ Printing without looping 1-1000