Python _ does not need to print 1-1000 cyclically, and python prints 1-1000
Question: I can print the 1000 numbers from 1 to on the screen. Do not use cyclic or conditional statements. Do not use them? : Operator. You are not allowed to use the method of listing output statements in the source code. For example, if you cannot use one thousand print statements, you will not repeat other silly behaviors. Answer:
Import syssys. setrecursionlimit (1005) def pr (n): print '% d' % n # t = int (1/(n-1000) if n <1000: pr (n + 1) # return None # return Nonepr (1)
I checked on the Internet and found that the default recursive depth of python is very limited, probably more than 900. When the recursive depth exceeds this value, this exception will be thrown. The solution is to manually set the recursive call depth:
Import sys. setrecursionlimit (1000000) # For example, set this parameter to 1 million
How does python use the for Loop Control to execute a custom function multiple times?
# In the script, you can write the import randomdef R (): print (random. randint () for I in range (): R ()
Python will generate random numbers cyclically.
Yes. However, according to your actual needs, many times you cannot use high-quality random numbers. That is to say, you cannot perceive loops at all. The loops are large and won't happen after thousands of records.
If you really need it, python has Mersenne Twister code, and the random number quality is very high. There is also a/dev/random generator in linux that is close to a real random number.