sum = 0
x = 1
n = 1
while True:
sum = sum + x
n = n + 1
x = 2**(n - 1)
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum = sum + x
n = n + 1
x = 2**(n - 1)
if n > 20:
break
print sum
2019-06-28
最赞回答 / Sapce
and 在 python 语法中返回的数值类型是布尔类型L[0] = 'Bart' and L[-1] = 'Adam' 返回的值是 fasle, 而不更改 L 中的值
2019-06-28
for x in [ '1', '2', '3', '4', '5', '6', '7', '8' ]:
for y in [ '2', '3', '4', '5', '6', '7', '8', '9' ]:
if x < y:
print x + y
for y in [ '2', '3', '4', '5', '6', '7', '8', '9' ]:
if x < y:
print x + y
2019-06-27
sum = 0
x = 0
while True:
x = x + 1
if not x % 2:
continue
if x > 100:
break
sum = sum + x;
print sum
x = 0
while True:
x = x + 1
if not x % 2:
continue
if x > 100:
break
sum = sum + x;
print sum
2019-06-27
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
x = 2 ** (n -1)
n = n + 1
sum = sum + x
print sum
x = 1
n = 1
while True:
if n > 20:
break
x = 2 ** (n -1)
n = n + 1
sum = sum + x
print sum
2019-06-27
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum = sum + score
print sum / 4
sum = 0.0
for score in L:
sum = sum + score
print sum / 4
2019-06-27
已采纳回答 / 慕勒9446969
首先,你要知道print语句可以跟上多个字符串,用逗号“,”隔开,就可以连成一串输出例如3-2做的习题 用两种方式打印出 hello, python.即 print'hello,python' 或 print'hello,','python' 同样,print语句可以跟上字符串和布尔值混合的形式,用逗号“,”隔开,就可以连成一串输出,该题就是这种情况,‘hello,’为字符串,a or 'world'为布尔值,两者用逗号“,”隔开了
2019-06-27
i=int('0x12fd2',16);
print i;
print bool(45678==i);
print i+45678
print 'Learn';
print "Python"
print bool(100<99)
b=int('0xff',16);
print bool(b==225)
print i;
print bool(45678==i);
print i+45678
print 'Learn';
print "Python"
print bool(100<99)
b=int('0xff',16);
print bool(b==225)
2019-06-27