本文目录一览

1,用python写一个程序

for gj in range(21): for mj in range(34): for xj in range(101): if (gj+mj+xj==100) and (gj*5+mj*3+xj/3==100): print(gj,mj,xj)

用python写一个程序

2,python的一个简单程序

#!/usr/bin/python# python 2.7n = int(raw_input())scores = []for i in range(n): score = int(raw_input()) scores.append(score if score > 60 else 0)print (sum(scores))

python的一个简单程序

3,请教一段python 代码

fr != [],即fr不是一个空列表,也就是说path文件不是空文件a=(),a是一个空元组(tuple)a=p[],a是一个空列表(list)
thefile=open(file_ame)open方法用来打开文件,并返回一个文件对象alltext=thefile.read()read方法一次读取文件的全部内容for line in thefile:文件对象是迭代的,用for可以一次读取一行

请教一段python 代码

4,求一个简单的Python给数字排序代码

123456789101112131415 defABC(a): fori inrange(0, len(a)-1): forj inrange(i+1, len(a)): if(a[i]>a[j]): t =a[i] a[i] =a[j] a[j] =t #test code as followsx =[5,2,3,7,1,8, 6,4]ABC(x)print(x) #result is:#[1,2,3,4,5,6,7,8] note:代码中的缩进不能省

5,用python 写一个简单计算代码急急急急 求大师

def getInteger(prompt, lowerlimit=0, upperlimit=None): while True: try: num = int(raw_input(prompt)) if num < lowerlimit: print "outof lower band", lowerlimit continue if upperlimit and upperlimit < num: print "outof upper band", upperlimit continue return num except: continuenums = sorted([ getInteger("Enter a number, which bigger than 0: "), getInteger("Enter a number, which bigger than 0: "), ])msg = "%d can not be deved by %d" if nums[1] % nums[0] else "%d can be deved by %d"print msg % (nums[1], nums[0])

文章TAG:python  简单  代码  代码大全  python简单代码大全  
下一篇