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