def firstCharUpper(s):
return s[0:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-04-18
s = "Python was started in 1989 by \"Guido\".\nPython is free and easy to learn."
print s
print s
2015-04-18
import math
def quadratic_equation(a, b, c):
delt = b*b - 4*a*c
x1 = (-b + math.sqrt(delt))/2/a
x2 = (-b - math.sqrt(delt))/2/a
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
delt = b*b - 4*a*c
x1 = (-b + math.sqrt(delt))/2/a
x2 = (-b - math.sqrt(delt))/2/a
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-04-17
def square_of_sum(L):
sum = 0
for i in L:
sum += i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum = 0
for i in L:
sum += i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-04-17
L = [75, 92, 59, 68]
sum = 0.0
for s in L:
sum = sum + s
print sum / 4
sum = 0.0
for s in L:
sum = sum + s
print sum / 4
2015-04-17
已采纳回答 / Ruskee
执行以本地python环境运行为准。网页提交啥的可能内部有bug如果元素只有三个,没有append过的话,那么,L[3]与L[-4] 都应该在执行的时候发生越界异常 IndexError
2015-04-16
修改成这样也错。。。输出好像没有错
m = ('A','B')
t = ('a', 'b', m)
print t
m = ('A','B')
t = ('a', 'b', m)
print t
2015-04-16
sum = 0
x = 0
while x<100:
sum=sum+(2*x+1)
x=x+1
print sum
x = 0
while x<100:
sum=sum+(2*x+1)
x=x+1
print sum
2015-04-16