www.fltk.net > 求python小程序代码练练手

求python小程序代码练练手

邮箱给我,私聊发给你

这个是 python2.7 的代码,如果是 python3.x 的话,改一下 print 函数就好。 if __name__ == '__main__': list_three = [] list_six = [] list_nine = [] for i in range(1, 301): if i % 3 == 0 or str(i).find('3') -1: list_three.append(i) ...

score是str类型,需要转成int. score=int(score)

import math #导入模块/库for i in range(1,10): #for循环语句 print math.sin(i) #print 输出for j in range(100): if j%2==0: #if 条件判断语句 print j,"是偶数" else: print j,"是奇数"data=[1,2,'c','d',5] #列表print data[2] #列表索引,...

raw_input返回的是字符串,得转换成数字,在pyhton2里字符串应该是永远大于数字的,所以会永远打赢正数’,而且0不是正数也不是负数 tmp=float(raw_input('please input a number\n')) if tmp > 0: print '正数' else: print '负数'

可能会有的错误: OverflowError: Python int too large to convert to C long 或者 OverflowError: range() result has too many items ,python的Int无限制,但C的int和long都会溢出,因为python的很多函数底层用C实现的,所以python有时也会出现这...

def is_odd(n, y=2): return n % y == 1 print list(filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15]))

我有,你留下QQ,我给你发过去,我写的一些练手的,比如算PI

用pygame编的游戏行不行? qq是:352281674 到时候给你图片和代码

while True: input = raw_input('Please enter something: ') try: input = int(input) if input%2 == 0: print input," is even number." else: print input," is odd number." except: input = str(input) if not ' ' in input: print input,"...

网站地图

All rights reserved Powered by www.fltk.net

copyright ©right 2010-2021。
www.fltk.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com