for x in [1,2,3,4,5,6,7,8,9]:
for y in [0,1,2,3,4,5,6,7,8,9]:
if x < y:
print 10*x+y
else:continue
for y in [0,1,2,3,4,5,6,7,8,9]:
if x < y:
print 10*x+y
else:continue
2020-06-14
sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==1:
sum+=x
else: continue
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
if x%2==1:
sum+=x
else: continue
print sum
2020-06-14
print(45678+(0x12fd2))
print('Learn python in imooc')
print(bool(100<99))
print(bool(0xff==255))
运行成功
print('Learn python in imooc')
print(bool(100<99))
print(bool(0xff==255))
运行成功
2020-06-12
a = 'python'
print 'hello,', a or 'world'
b = ''
print 'hello,', b or 'world'
在这里,a=true,所以第2行运行结果返回a
b等于空值,等于fales,非空值的world默认为true,第4行运行结果返回world
print 'hello,', a or 'world'
b = ''
print 'hello,', b or 'world'
在这里,a=true,所以第2行运行结果返回a
b等于空值,等于fales,非空值的world默认为true,第4行运行结果返回world
2020-06-12
def move(n, a, b, c):
if n ==1 :
print a,"-->",c
return
print a,"-->",b
move(n-1, a, b, c)
print b,"-->",c
move(4, 'A', 'B', 'C')
if n ==1 :
print a,"-->",c
return
print a,"-->",b
move(n-1, a, b, c)
print b,"-->",c
move(4, 'A', 'B', 'C')
2020-06-09
最新回答 / 慕运维3398011
x=x*2会报错,这是赋值语句,==才是判断是否等于。而且你的continue放在最后,不管判断出什么结果,都是进入下一个循环,最后计算的是1到100相加。给你看一下我的。因为是奇数相加,x从0开始,所以我这里循环最开始就是x自增,之后先判断x是否越界,再判断x的奇偶。越界直接结束跳出给结果,奇数加到sum上,偶数直接进入下一个循环,即x自增,变成奇数。以此循环。<...code...>
2020-06-08
已采纳回答 / 谢erduo
print(45678+(0x12fd2)): 45678是十进制,0x12fd2因为有f所以被识别为16进制,0x12fd2的十进制为77778,45678+77778=123456;print(100<99)和print((0xff)==255)是布尔运算,判断括号里的式子true or false,输出的是true or false
2020-06-07