def firstCharUpper(s):
return s.upper()[0]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s.upper()[0]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2018-10-31
L=['Adam','Lisa','Paul','Bart'];
L.pop(-1);
L.pop(0);
print;
这样执行也可以啊
L.pop(-1);
L.pop(0);
print;
这样执行也可以啊
2018-10-31
print [x*101+y*10 for x in range(1,10) for y in range(0,10)]
二重不是更简单
二重不是更简单
2018-10-31
# -*- coding: utf-8 -*-
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
### 删掉 u 字符就行了,因为开头已经定义编码
print r'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
### 删掉 u 字符就行了,因为开头已经定义编码
2018-10-31
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
### 注意审题= =|||
Whether it's nobler in the mind to suffer.'''
### 注意审题= =|||
2018-10-31
#s='Python was started in 1989 by "Guido".Python is free and easy to learn.'
#print(s)
s="Python was started in 1989 by \"Guido\".Python is free and easy to learn."
print(s)
有两种表示方法
#print(s)
s="Python was started in 1989 by \"Guido\".Python is free and easy to learn."
print(s)
有两种表示方法
2018-10-31
`
x1 = 1
d = 3
n = 100
x100= x1 + (n-x1)*d
s =( x100+x1)*n/2
print s
`
x1 = 1
d = 3
n = 100
x100= x1 + (n-x1)*d
s =( x100+x1)*n/2
print s
`
2018-10-31
def average(*args):
n=0
sum=0.0
if args==():
return 0.0
else:
for x in args:
sum+=x
n+=1
return sum/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
n=0
sum=0.0
if args==():
return 0.0
else:
for x in args:
sum+=x
n+=1
return sum/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-10-30
d = b*b - 4*a*c
if a == 0:
if b == 0:
if c == 0:
return 0
else:
return 'error'
return c/b
elif d >= 0:
e = math.sqrt(d)
x1 = (-b+e)/(2*a)
x2 = (-b-e)/(2*a)
return x1, x2
if a == 0:
if b == 0:
if c == 0:
return 0
else:
return 'error'
return c/b
elif d >= 0:
e = math.sqrt(d)
x1 = (-b+e)/(2*a)
x2 = (-b-e)/(2*a)
return x1, x2
2018-10-30
没按老师要求的变量来,这样做的答案也是对的
sum = 0;
a = 1;
for i in range(1,100):
a = a+3;
sum +=a;
s = sum+1;
print s
sum = 0;
a = 1;
for i in range(1,100):
a = a+3;
sum +=a;
s = sum+1;
print s
2018-10-30
move(a,b,c)执行了a到b,a到c,b到c的过程,其中a到b的过程要重复进行a到c的过程,所以b,c交换位置,move(a,c,b),a到c的过程是只移动了一个盘子,不存在重复操作,直接输出即可,同理b到c的过程,重复进行a到c的过程,a,b交换位置move(b,a,c),自己是这样理解的
2018-10-29