2013年10月12日

Python学习 Part2:深入Python函数定义

摘要: 在Python中,可以定义包含若干参数的函数,这里有几种可用的形式,也可以混合使用:1. 默认参数最常用的一种形式是为一个或多个参数指定默认值。>>> def ask_ok(prompt,retries=4,complaint='Yes or no Please!'): while True: ok=input(prompt) if ok in ('y','ye','yes'): return True if ok in ('n','no','nop','n 阅读全文

posted @ 2013-10-12 17:20 LilianChen 阅读(7550) 评论(1) 推荐(1) 编辑

Python 学习 Part1

摘要: 1. 斐波那契数序列>>> a,b=0,1>>> a0>>> b1>>> while b>> a,b=0,1>>> while b>> x=int(input("Please enter an integer: "))Please enter an integer: 42>>> if x>> a=["cat","window","defenstrate"]>>& 阅读全文

posted @ 2013-10-12 14:36 LilianChen 阅读(718) 评论(0) 推荐(1) 编辑

导航