# 科协python讲座摸鱼(Science and Technology Association Python lecture fishing)-python

## 科协python讲座摸鱼(Science and Technology Association Python lecture fishing)

py现在对我最大的作用可能是解决一些离谱的算法题，一些数据结构之类的

### 冒泡排序：

``````def bubble_sort(data, flag) :
if not flag:
for i in range(len(data) - 1):
for j in range(len(data) - 1 - i) :
if data[j] > data[j + 1] :
data[j], data[j + 1] = data[j + 1], data[j]
return data
else :
for i in range(len(data) - 1):
for j in range(len(data) - 1 - i) :
if data[j] < data[j + 1] :
data[j], data[j + 1] = data[j + 1], data[j]
return data
``````

``````a = [1, 2, 3, 4, 5, 6]
bubble_sort(a, 0)
#`[1, 2, 3, 4, 5, 6]
a = [1, 2, 3, 4, 5, 6]
bubble_sort(a, 1)
#`[6, 5, 4, 3, 2, 1]`
``````
————————

Py’s biggest effect on me now may be to solve some outrageous algorithm problems, some data structures and so on
For example, when learning high precision in winter vacation, I came into contact with the big integer class BigInteger of py
Fish while listening to the lecture:

### Bubble sort:

``````def bubble_sort(data, flag) :
if not flag:
for i in range(len(data) - 1):
for j in range(len(data) - 1 - i) :
if data[j] > data[j + 1] :
data[j], data[j + 1] = data[j + 1], data[j]
return data
else :
for i in range(len(data) - 1):
for j in range(len(data) - 1 - i) :
if data[j] < data[j + 1] :
data[j], data[j + 1] = data[j + 1], data[j]
return data
``````

Runtime input tuple:

``````a = [1, 2, 3, 4, 5, 6]
bubble_sort(a, 0)
#`[1, 2, 3, 4, 5, 6]
a = [1, 2, 3, 4, 5, 6]
bubble_sort(a, 1)
#`[6, 5, 4, 3, 2, 1]`
``````