
Python
阳明学徒
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python小游戏
Python数学函数 函数 返回值 ( 描述 ) abs(x) 返回数字的绝对值,如abs(-10) 返回 10 ceil(x) 返回数字的上入整数,如math.ceil(4.1) 返回 5 cmp(x, y) 如果 x < y 返回 -1, 如果 x == y 返回 0, 如果 x > y 返回 1 exp(x) 返回e的x次幂(ex),如math.exp(1) ...转载 2018-03-15 11:20:12 · 606 阅读 · 0 评论 -
python小游戏
from random import randint board = [] for x in range(0, 5): board.append(["O"] * 5) def print_board(board): for row in board: print " ".join(row) print_board(board) def random_row(board):...转载 2018-03-12 15:25:02 · 535 阅读 · 0 评论 -
Python递归解释
def fact(n): if n==1: return 1 return n*fact(n-1) print(fact(5))#120 原理: #素数---埃拉托色尼筛选法 def _odd_iter(): n = 1 while True: n = n + 2 yield n def _not_di...原创 2018-03-21 15:15:04 · 473 阅读 · 0 评论 -
python中的字符数字之间的转换函数
转载:http://www.cnblogs.com/wuxiangli/p/6046800.html int(x [,base ]) 将x转换为一个整数 long(x [,base ]) 将x转换为一个长整数 float(x ) 将x转换到一个浮点数 complex(real [,imag ]) 创建一个复数 str(x ) ...转载 2018-04-03 16:21:56 · 201 阅读 · 0 评论 -
python输出1到100之和的几种方法
使用内建函数range print sum(range(1,101)) 使用函数reduce print reduce(lambda a,b:a+b,range(1,101)) 使用循环 n = 0 for x in range(101): n = x + n转载 2018-04-26 11:20:55 · 37179 阅读 · 3 评论