.


:




:

































 

 

 

 


map




. . A:

L=list(map(lambda x:x[0],A))

Lambda-

lambda x:x[0]

. A ( ). map Python , , , "" , "map()". , list().

map , lambda - def, .

map lambda -:

print (list(map(float,'2222!3333!0.1'.split('!'))))

float.

map , . matplotlib plot X Y. , , , :

plt.plot(list(map(lambda x:x[0],A)),list(map(lambda x:x[1],A)))

, numpy ( . ):

a=np.array(A)

plt.plot(a[:,0],a[:,1])

map , numpy. , .

, .

, , . , . , . , , , .

.

, . , . , , . , . , .

, - . , , . , , . , , , .

, .

. ( [2])

( ) (1170-1240), (1202), . , , . 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 .

, , 0.618 ( ), 1.618. - , , .

, n- . , : f 1 = f 2 =1, f n= f n−1+ f n−2,n∈ℕ. ? , fn=f n−1+f n−2, f 1 = f 2 =1, :

def fibonacci(n):

if n == 1 or n == 2:

return 1

return fibonacci(n-1) + fibonacci(n-2)

print (fibonacci(7))

13, .

.

import random

L=[random.randrange(100) for i in range(1,20)]#

print (L)

 

def mysort(L):

for i in range(0,len(L)-1):#

if L[i]>L[i+1]: # ,

L=L[:i]+[L[i+1],L[i]]+L[i+2:] # 蠠

return mysort(L) # mysort(L),

# 󠠠

return L # , , mysort(L) -

 

print (mysort(L)) # mysort(L)

. 80 .

, ( - ):

"""

(. http://elementy.ru/posters/fractals/dragon)

GNU General Public License

() , 2015 .

"""

import matplotlib.pyplot as plt # matplotlib.pyplot pll

 

import numpy as np

A=[[0,0],[1,1],[2,0]] #

for k in range(0,18): #

for i in range(0,len(A)-1): # ,

#

A.insert(i*2+1,[0.5*A[i*2][0]+0.5*A[i*2+1][0]-(i%2-0.5)*(A[i*2][1]-A[i*2+1][1]),

0.5*A[i*2][1]+0.5*A[i*2+1][1]+(i%2-0.5)*(A[i*2][0]-A[i*2+1][0])])

plt.plot(list(map(lambda x:x[0],A)),list(map(lambda x:x[1],A)))#

plt.show()

:

, , .

1- :

2- :

18- :

Python .

, , . .





:


: 2018-10-15; !; : 777 |


:

:

, .
==> ...

1718 - | 1501 -


© 2015-2024 lektsii.org - -

: 0.014 .