Just how powerful Python Python code which can be achieved

Just how powerful python? What features of Python code to achieve? As we all know, Python entry is simple, powerful, is the best era of artificial intelligence programming language. But many people wonder just how powerful Python, why so popular? Here's to reveal the answer to you, look at the line of Python exactly what functions can be realized!

 

Just how powerful Python Python code which can be achieved

 

 

 

1, the multiplication table

print('

'.join([' '.join(['%s*%s=%-2s' % (y, x, x*y) for y in range(1, x+1)]) for x in range(1, 10)]))

2, the print heart-shaped pattern

print('

'.join([''.join([('AndyLove'[(x-y)%8]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-30,30)])for y in range(15,-15,-1)]))

3, dynamic propeller

exec("""

from turtle import *

for i in range(500):

forward(i)

left(91)

""")

4, calculates the number of prime within 1-100

print(' '.join([str(item) for item in filter(lambda x: not [x % i for i in range(2, x) if x % i == 0], range(2, 101))]))

5, the output Fibonacci number

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(30)]])

6, the algorithm to achieve fast row

quickSort = lambda array: array if len(array) <= 1 else quickSort([item for item in array[1:] if item <= array[0]]) + [array[0]] + quickSort([item for item in array[1:] if item > array[0]])

array = [9, 11, 88, 32, 8]

print(quickSort(array))

7, in-line maze

cmd command input single-wire maze under the following code.

python -c "while 1:import random;print(random.choice('|| __'), end='')"

8, 1000 solving power of 2 and the sum of all of you

2 of the 1000 value of great power, the results add up how much each digit is equal to it?

print (sum (map (int, str (2 ** 1000)))) # 1366 Results

Of course, from coding standards and practical point of view, a line of Python code can realize the function somewhat one-sided, but it is undeniable Python function really strong, which is mainly dependent on its abundance of unique advantages. Python syntax is simple, less constrained, adhesive water contains many rich and powerful third-party modules / frameworks. Commonly used are the following:

1) Scrapy. Scrapy is a website for crawling data, extract structured data written application framework that can be used in data mining, a series of program information for processing or storage of historical data. Scrapy wide range of uses, can be used for data mining, monitoring and automated testing.

2) Numpy. Numpy Python is considered one of the most popular machine learning library, with strong interactivity and ease of use, enabling complex mathematical implementation is very simple. Images, and other binary acoustic Numpy original stream interface may be used to represent a real number of N-dimensional array.

3) Keras. Keras is considered one of the coolest machine learning Python library. It provides a mechanism easier to express neural network. Keras also compilation model, processing the data set, a graphical visualization provides some of the best utility.

4) Pandas. Pandas are in machine learning Python library that provides high-level data structures and a variety of analysis tools, one of the biggest feature of this library is able to use twelve command to convert complex operations with data. Pandas has many built-in methods to packet data merging, filtering, and time series functions.

Guess you like

Origin blog.csdn.net/java276582434/article/details/92686381