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-06-29
请你们想一想下面那个是正确的
sum = 0
x = 1
while x<100:
sum=sum+x
x=x+2
print sum
sum = 0
x = 1
while x<100:
x=x+2
sum=sum+x
print sum
sum = 0
x = 1
while x<100:
sum=sum+x
x=x+2
print sum
sum = 0
x = 1
while x<100:
x=x+2
sum=sum+x
print sum
2019-06-29
def average(*args):
s = 0.0
if len(args) == 0:
return s
return sum(args) * 1.0 / len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
s = 0.0
if len(args) == 0:
return s
return sum(args) * 1.0 / len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-06-28
def greet(s = ''):
if not s:
s = 'world'
print 'Hello, ' + s + '.'
greet()
greet('Bart')
if not s:
s = 'world'
print 'Hello, ' + s + '.'
greet()
greet('Bart')
2019-06-28
sum = 0
x = 1
n = 1
while True:
sum = sum + x
n = n + 1
x = 2**(n - 1)
if n > 20:
break
print sum
x = 1
n = 1
while True:
sum = sum + x
n = n + 1
x = 2**(n - 1)
if n > 20:
break
print sum
2019-06-28
for x in [ '1', '2', '3', '4', '5', '6', '7', '8' ]:
for y in [ '2', '3', '4', '5', '6', '7', '8', '9' ]:
if x < y:
print x + y
for y in [ '2', '3', '4', '5', '6', '7', '8', '9' ]:
if x < y:
print x + y
2019-06-27
sum = 0
x = 0
while True:
x = x + 1
if not x % 2:
continue
if x > 100:
break
sum = sum + x;
print sum
x = 0
while True:
x = x + 1
if not x % 2:
continue
if x > 100:
break
sum = sum + x;
print sum
2019-06-27
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
x = 2 ** (n -1)
n = n + 1
sum = sum + x
print sum
x = 1
n = 1
while True:
if n > 20:
break
x = 2 ** (n -1)
n = n + 1
sum = sum + x
print sum
2019-06-27
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum = sum + score
print sum / 4
sum = 0.0
for score in L:
sum = sum + score
print sum / 4
2019-06-27
i=int('0x12fd2',16);
print i;
print bool(45678==i);
print i+45678
print 'Learn';
print "Python"
print bool(100<99)
b=int('0xff',16);
print bool(b==225)
print i;
print bool(45678==i);
print i+45678
print 'Learn';
print "Python"
print bool(100<99)
b=int('0xff',16);
print bool(b==225)
2019-06-27