2019年4月26日
摘要: 字符串String 一个字符的序列 使用成对的单引号或双引号括起来 或者三引号""" 和 ''' 表示块注释 字符串运算 长度 len()函数 first_name = 'Michael' len(first_name) 7 拼接 + name = first_name + 'Jordan' pri 阅读全文
posted @ 2019-04-26 22:30 destiny_sea 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 递归:程序调用自身 形式:在函数定义有直接或间接调用自身 阶乘:N!=1 2 3 ... N def p(n): x = 1 i = 1 while i 阅读全文
posted @ 2019-04-26 15:01 destiny_sea 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 函数 完成特定功能的一个语句组,这组语句可以作为一个单位使用,并且给它取一个名字 通过函数名执行 数学 function(x) = x^2 2x + 1 abs(x) 求x的绝对值 定义函数 定义和调用函数 函数参数 缺省参数 返回值 函数调用完成后,返回数据 return语句终止当前函数的执行 r 阅读全文
posted @ 2019-04-26 14:01 destiny_sea 阅读(196) 评论(0) 推荐(0) 编辑
摘要: +二分法求平方根 x = float(raw_input('Enter the number')) low = 0 high = x guess = (low + high ) / 2 if x 1e 5: if guess 2 阅读全文
posted @ 2019-04-26 11:17 destiny_sea 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 程序流程图 顺序结构 选择结构 if if else if 语句 嵌套结构(Nested) 多分支结构(Chained) if score = 90: print 'ARM' elif score = 80: print 'B' elif score = 70: print 'C' elif sco 阅读全文
posted @ 2019-04-26 01:17 destiny_sea 阅读(173) 评论(0) 推荐(0) 编辑