已采纳回答 / 黑夜的白_羊
你的是逻辑问题
import math def square_of_sum(L): sum=0 for x in L: sum=sum+math.sqrt(x) return sum print(square_of_sum([1,2,3,4]))你的代码问题,先不看sqrt()函数,看如下你的代...
2020-02-28
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2.0
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x1+x100)*n/2.0
print s
2020-02-27
已采纳回答 / 慕粉0728521634
因为你/2.0*a没有用括号括起来实际上运行的是先/2.0再*ax1=(-b+math.sqrt(b**2-4.0*a*c))/(2.0*a)x2=(-b-math.sqrt(b**2-4.0*a*c))/(2.0*a)就可以了
2020-02-27
在WIN10里修改环境变量,前几个步骤都一样,到选择PATH改变变量值那一步,是用新建,把python文件夹位置写上就行了。
2020-02-27
def firstCharUpper(s):
if len(s) <= 0 :
return
A = s[0:1].upper()
return A+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
if len(s) <= 0 :
return
A = s[0:1].upper()
return A+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2020-02-26
def average(*args):
sum = 0
for i in args :
sum += i
if len(args) == 0 :
return 0.0
return sum / (len(args) * 1.0 )
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0
for i in args :
sum += i
if len(args) == 0 :
return 0.0
return sum / (len(args) * 1.0 )
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2020-02-26
最新回答 / 277csr
你的for、else后面都没有:而且你只进行了一次判断就输出了,我的思路大概和你差不多,我的是这样的s = set(['Adam', 'Lisa', 'Paul'])L = ['Adam', 'Lisa', 'Bart', 'Paul']for x in L: if x in s: s.remove(x) else: s.add(x)print s
2020-02-26