Python 学习
tonywang1945yes
这个作者很懒,什么都没留下…
展开
-
Python (1) 性能试验:斐波那契数列
def fib(k): #打印 if(k==0 or k==1): return 1 else : return fib(k-1)+fib(k-2)for x in range(60): print (x,"的Fib值是",fib(x))同样采用递归计算斐波那契数列,在相同硬件下,Python程序可以瞬间算到Fib(31),而C+...原创 2018-03-05 17:07:44 · 488 阅读 · 0 评论 -
Python (2) :命令行输入与输出
命令行输入输出是一门语言最基本的操作,下面举例探索一下Python 的命令行输入输出写法。打印字符串:print('hello,world')逗号隔开自动补空格,语句末自动换行print('hello,world','hello')print('world!!')可以打印算式print(2+3)x=2print(x+3)y=3print(x+y)获取输入:x=input()prin...原创 2018-03-05 17:23:21 · 6692 阅读 · 0 评论 -
Python (3): 小常识
1,Python 没有自增运算符2,字符串用+连接,用[]分割x="hello,world"x=x[:2]+'python'+x[2:]print(x)3, 逻辑运算如下,注意True False 大写x=Truey=Falseprint(x or y)print (x and y)print(not x)4,string 转 intc=input()if c.isdigit():...原创 2018-03-05 17:57:20 · 130 阅读 · 0 评论 -
Python(4) 基本数据结构1
与Java,C++ 不同,Python 使用了list (线性表)作为基本数据结构,其基本用法如下:A=[1,2,3,4,5,6,7]print(A[0])原创 2018-03-05 19:11:56 · 144 阅读 · 0 评论