這個代碼不可以,因為L.pop(2)之后Candy出去了,現在要退學的David是在第二個位置,所以下一個位置還是需要pop(2)
2020-09-18
# Enter a code
# -*- encoding:utf-8 -*-
width=1.57
height=3.14
m3=width*height
m3=round(m3,3)
print("長方形的面積為"+str(m3))
# -*- encoding:utf-8 -*-
width=1.57
height=3.14
m3=width*height
m3=round(m3,3)
print("長方形的面積為"+str(m3))
2020-09-18
# Enter a code
a="python"
print("hello,",a or "world")
b=""
print("hello,", b or "world")
#在計算a or b時,如果 a 是 True,則根據或運算法則,整個計算結果必定為 True,因此返回 a;如果 a 是 False,則整個計算結果必定取決于 b,因此返回 b
a="python"
print("hello,",a or "world")
b=""
print("hello,", b or "world")
#在計算a or b時,如果 a 是 True,則根據或運算法則,整個計算結果必定為 True,因此返回 a;如果 a 是 False,則整個計算結果必定取決于 b,因此返回 b
2020-09-15
ch是在for循環中定義的,意思是把字符串s中的每一個元素依次賦值給ch,然后再把ch打印出來,直到打印出字符串s的最后一個字符為止。
2020-09-15
L = [[1, 2, 3], [5, 3, 2], [7, 3, 2]]
s1=L[0][0]*L[0][1]*L[0][2]
print(s1)
s1=L[0][0]*L[0][1]*L[0][2]
print(s1)
2020-09-10
# Enter a code
L = ['Alice', 66, 'Bob', True, 'False', 100]
i=0
while i<=5:
if i%2!=0:
print (L[i])
i=i+1
L = ['Alice', 66, 'Bob', True, 'False', 100]
i=0
while i<=5:
if i%2!=0:
print (L[i])
i=i+1
2020-09-09
參考答案有問題吧,應該是
hello='Hello'
space=' '
world='World'
print(hello+space +world)
hello='Hello'
space=' '
world='World'
print(hello+space +world)
2020-09-09
L = ['Alice', 66, 'Bob', True, 'False', 100]
for item in L:
i=L.index(item)
if(i%2)!=0:
print(item)
for item in L:
i=L.index(item)
if(i%2)!=0:
print(item)
2020-09-09
age = 19
if age>=18:
print('adult'+' '+str(age))
if age>=18:
print('adult'+' '+str(age))
2020-09-07