最新回答 / HHHHHoliday
sum=0.0是初始化一个浮点数(因为平均数有可能是小数),sum+=name代表将所有name的值加到sum中,最后的print语句就是输出平均数啦
2019-03-26
最新回答 / 慕无忌2417405
这是之前定义了一个move函数,根据move函数x = 100(第一个100) +60*math.cos(math.pi/6) y = 100(第二个100) -60*math.sin(math.pi/6)print x,y被作为一个序列打印了下来
2019-03-26
if-else系列只有一个会执行,如果想两个都执行那就写两个if就行了,不要用if-else
2019-03-26
def firstCharUpper(s):
return s[0].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2019-03-26
已采纳回答 / 慕仰6034142
# -*- coding: utf-8 -*-L=['王',100,'孙',99]print str(L).decode('string_escape')
2019-03-26
def average(*args):
length = len(args)
if length == 0:
return 0.0
s = float(sum(args))
return s/length
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
length = len(args)
if length == 0:
return 0.0
s = float(sum(args))
return s/length
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-03-26
L = ['Adam', 'Lisa', 'Bart']
t=L[0]
L[0]=L[2]
L[2]=t;
print L
t=L[0]
L[0]=L[2]
L[2]=t;
print L
2019-03-25
def firstCharUpper(s):
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2019-03-25