You may have seen a similar Python line of code that can be implemented online, such as:
99 Multiplication Table:
Print (". Join" (['%s*%s=%-2s '% (y,x,x*y) for Y in range (1,x+1)]) "For X in Range (1,10)])
or output the value of the first 100 Fibonacci sequences:
Print ([x[0] for x in [(A[i][0], A.append ((A[i][1], a[i][0]+a[i][1]))))-A In ([[[[]],) ' For I in range (100)]])
Well, these can be done, then the following cool code, more worthy of a look!
Single-line maze (input under cmd):
Python-c "while 1:import random;print (Random.choice (' | | | __ '), end= ') "
Emmmm, this may be more abstract, then try to change the characters inside, such as the following code python-c "while 1:import random;print (Random.choice (' ╱╲ '), end= ')"
This maze effect is OK!
Guess numbers
A lot of tutorials have this small case, then you use a few lines? Try the following.
Python-c "Import random;n=random.randint (1,99); [(Lambda a:print (' Y ' if a==n Else ' H ' if a>n Else ' L '))) (int (input ()))) for I in range (6)] "
Yes, you have not read wrong, a line of code can achieve this function!
100 Foot Golf
Referring to the Angry Birds, the goal is to get the golf to just 100 feet, not much more!
Import math as M;a,v=eval (input ()); [Print ('%03d '%x+ ' *m.floor (0.5+x*m.tan (a)-x*x/(V*m.cos (a))) + ' O ') for x in range (102)]
You need to enter 2 parameters, which is the angle and speed of golf!
At last
Most of the techniques used by these codes should look familiar:
List parsing, lambda expressions and random integers, with a combination of several functions, can write cool code!
Magic python, what kind of cool things can one line of code do?