One line of code outputs the shape of a heart with the specific character “Love”

Print (' \ n '. Join ([(' Love ' ' '. Join ([[(x-y) % len (' Love ')] the if ((0.05) x * * * 2 + 0.1) (y * * * 2-1) 3 - (0.05) x * * * * * 2 * * * 3 (y * 0.1) < = 0 the else  ' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))Copy the code

Output:

                veLoveLov           veLoveLov               
            eLoveLoveLoveLove   eLoveLoveLoveLove           
          veLoveLoveLoveLoveLoveLoveLoveLoveLoveLov         
         veLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveL        
        veLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLov       
        eLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLove       
        LoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveL       
        oveLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLo       
        veLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLov       
        eLoveLoveLoveLoveLoveLoveLoveLoveLoveLoveLove       
         oveLoveLoveLoveLoveLoveLoveLoveLoveLoveLove        
          eLoveLoveLoveLoveLoveLoveLoveLoveLoveLove         
          LoveLoveLoveLoveLoveLoveLoveLoveLoveLoveL         
            eLoveLoveLoveLoveLoveLoveLoveLoveLove           
             oveLoveLoveLoveLoveLoveLoveLoveLove            
              eLoveLoveLoveLoveLoveLoveLoveLove             
                veLoveLoveLoveLoveLoveLoveLov               
                  oveLoveLoveLoveLoveLoveLo                 
                    LoveLoveLoveLoveLoveL                   
                       LoveLoveLoveLov                      
                          LoveLoveL                         
                             Lov                            
                              v                             Copy the code

One line of code prints the multiplication table

print('\n'.join([' '.join(['%s*%s=%-2s' % (y, x, x*y) for y in range(1, x+1)]) for x in range(1, 10)]))Copy the code

Output:

1 * 1 * 2 = 2 1 = 1, 2 * 2 = 4 1 2 * 3 * 3 = 3 = 3 * 3 = 6 to 9 1 * 4 = 4 and 2 * 4 = 8 3 * 4 = 12 4 * 4 = 16 1 * 5 = 5 2 * 5 = 3 * 10 4 5 = 15 * 5 = 5 * 5 = 20 1 * 6 = 2 * 6 = 12 3 * 6 = 18 4*6=24 5*6=30 6*6=36 1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64 1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81Copy the code

One line of code outputs the first 10 Fibonacci numbers

print([x[0] for x in [(a[i][0], a.append([a[i][1], a[i][0]+a[i][1]])) for a in ([[1, 1]], ) for i in range(10)]])Copy the code

Output:

[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]Copy the code

One line of code outputs the Mandelbrot image (I think it looks like a turtle)

Each position in the Mandelbrot image corresponds to a complex number in the formula N=x+y* I

print('\n'.join([''.join(['*'if abs((lambda a: lambda z, c, n: a(a, z, c, n))(lambda s, z, c, n: Z if n == 0 else s(s, z*z+c, c, n-1))(0, 0.02*x+0.05j*y, 40)) < 2 else "for x in range(-80, 20)]) for y in range(-20, 20)]))Copy the code

Output:

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *Copy the code

One line of code outputs a nice diamond

[print('\n'.join(" "*abs(i)+"* "*(n-abs(i))for i in range(-n+1,n))) for n in[9]]Copy the code

Output:

        * 
       * * 
      * * * 
     * * * * 
    * * * * * 
   * * * * * * 
  * * * * * * * 
 * * * * * * * * 
* * * * * * * * * 
 * * * * * * * * 
  * * * * * * * 
   * * * * * * 
    * * * * * 
     * * * * 
      * * * 
       * * 
        *Copy the code

One line of code outputs primes between 1 and 100

print(' '.join([str(item) for item in filter(lambda x: all(map(lambda p: x % p != 0, range(2, x))), range(2, 101))]))Copy the code

Output:

37 41 43 47 53 59 61 67 71 73 79 83 89 97Copy the code

Want to further understand the programming development related knowledge, grow and progress with me, please pay attention to my public account “pinecone warehouse”, share all kinds of resources of house & programmer, thank you!!