sum = 0
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
x = x * 2
n = n + 1
print sum
x = 1
n = 1
while True:
if n > 20:
break
sum = sum + x
x = x * 2
n = n + 1
print sum
2017-03-23
sum = 0
x = 1
n = 1
while True:
sum = sum + x
x =2*(n-1)
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum = sum + x
x =2*(n-1)
if n > 20:
break
print sum
2017-03-23
>>>store = 75
>>> if store >= 60:
... print 'Bart store is',store
... print 'passed'
...
Bart store is 75
passed
>>> if store >= 60:
... print 'Bart store is',store
... print 'passed'
...
Bart store is 75
passed
2017-03-23
>>>store = 75
>>> if store >= 60:
... print 'Bart store is',store
... print 'passed'
...
Bart store is 20
passed
>>> if store >= 60:
... print 'Bart store is',store
... print 'passed'
...
Bart store is 20
passed
2017-03-23
t = ('Adam',)
print t
运行结果:('Adam',)
#如何将最后的逗号去掉?
t = tuple('Adam')
print t
运行结果:('A', 'd', 'a', 'm')
print t
运行结果:('Adam',)
#如何将最后的逗号去掉?
t = tuple('Adam')
print t
运行结果:('A', 'd', 'a', 'm')
2017-03-23
t = tuple('Adam')
print t
运行结果:('A', 'd', 'a', 'm')
print t
运行结果:('A', 'd', 'a', 'm')
2017-03-23
L = []
i=1
while i <101:
L.append(i*i)
i=i+1
print sum(L)
i=1
while i <101:
L.append(i*i)
i=i+1
print sum(L)
2017-03-23
最赞回答 / qq_醉月飞羽觞_0
没有这样的吧,就算是c/c++/java中也是在函数名前面添加返回的类型吧,如int getReturn(); return 返回的类型就是函数名前面的类型int。而python 中没有给变量声明类型,所以说return 1 根据return 后的数据类型来确定为整型(如果省略写法是return 1,2 ,则完整写法return (1, 2) 所以容易知道tuple类型, 即把return 后面的复制给一个变量,根据这个变量的类型确定我们返回值的类型),相当于c:int get(){ ...
2017-03-23
print ('hello,python')
print ('hello,''python')
print ('hello,'+'python')
print 'hello,python'
print ('hello,''python')
print ('hello,'+'python')
print 'hello,python'
2017-03-23