Python practice

来源:互联网 发布:北京知豆电动汽车4s店 编辑:程序博客网 时间:2024/06/18 18:15

Today, I learn to use the commanding prompt of python(python shell). And also practice some easy syntax in python.


Here is an easy sorting function I wrote :


num = []tot = int(input("please input the number of members:\n"))for i in range(tot):    num.append(int((input())))for i in range(tot):    for j in range(tot - i - 1):        if num[i] > num[j + i + 1]:            t = num[i]            num[i] = num[j + i + 1]            num[j + i + 1] = tfor i in range(tot):    print(num[i])



It could be better I think, cause there are too many uncomfortable expression. which I think could be written more naturally.

原创粉丝点击