How to use one line of Python code to achieve some small functions
This article mainly shows you "how to use a line of Python code to achieve some small functions", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use a line of Python code to achieve some small functions" this article.
1. Print the multiplication formula with one line of code
Print ('\ n'.join (['. Join (["% 2s x% 2s =% 2s"% (jjre iPersoniLigj) for j in range (1dint 1)]) for i in range (1meme 10)])
two。 One line of code to print the maze
Print ('. Join (_ _ import__ ('random'). Choice ('\ u2571\ u2572') for i in range (50 / 24)
3. One line of code to express love
Print ('\ n'.join (['.join) ([(' Love' [(Xmury)% len ('Love')] if) ((xpend0.05) * * 2 + (yellow0.1) * * 2-1) * * 3-(xpend0.05) * * 2* (yawp0.1) * * 3