易截截图软件、单文件、免安装、纯绿色、仅160KB

python算法实践5 直接选择排序

#直接选择排序
def SelectSort(mylist):
size = len(mylist)
i = 0
for i in range(0, size):
k = i
for j in range(i + 1, size):
if mylist[j] < mylist[k]:
k = j

if k != i:
tmp = mylist[i]
mylist[i] = mylist[k]
mylist[k] = tmp

mylist0 = [11, 2, 3, 4, 112, 100]
SelectSort(mylist0)
print(mylist0)


相关文档:

python 如何返回多个值

如何写一个返回多个值的函数
函数的return 语句只能返回一个值,可以是任何类型。
因此,我们可以“返回一个 tuple类型,来间接达到返回多个值
”。
例:   x 除以 y 的余数与商的函数
def    F1 ( x, y ):
         a = x % y
  ......

Python的内存泄漏及gc模块的使用

Python的内存泄漏及gc模块的使用
                  -- 6.11日错误修正版
            
Horin|贺勤
        Email: horin153@msn.com ......

Python 使用C代码——swig

Ref : http://www.swig.org/translations/chinese/tutorial.html
假设你有一些c你想再加Python.。举例来说有这么一个文件example.c
 /* File : example.c */
 #include <time.h>
 double My_variable = 3.0;
 int fact(int n) {
     if (n <= 1) return 1;
&nbs ......

example of python operator overloadind

And last here is the overload operators example:
# map() takes two (or more) arguments, a function and a list to apply the function to
# lambda can be put anywhere a function is expected
# map() calls lambada for every element in the self list
# since Vector has overloaded __getitem__ and __len_ ......

python字典排序

python字典排序
1、 
准备知识:
在python里,字典dictionary是内置的数据类型,是个无序的存储结构,每一元素是key-value对:
如:dict = {‘username’:‘password’,‘database’:‘master’},其中‘username’和& ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号