sum = 0
x = 1
while x<50:
sum=sum+(2*x-1)
x=x+1
print sum
x = 1
while x<50:
sum=sum+(2*x-1)
x=x+1
print sum
2019-04-13
def toUppers(L):
return [x.upper() for x in L if isinstance(x, str) ]
print toUppers(['Hello', 'world', 101])
return [x.upper() for x in L if isinstance(x, str) ]
print toUppers(['Hello', 'world', 101])
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum*1.0/len(d)
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum*1.0/len(d)
2019-04-13
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for index, name in zip(range(1,5),L):
print index, '-', name
for index, name in zip(range(1,5),L):
print index, '-', name
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.'''
2019-04-13
如果是‘hello,’‘python’,则hello,python的逗号之后没有空格,如果是‘hello,’,‘python’,逗号之后还会有一个空格;
2019-04-13
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-04-12