for x in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
for y in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
if x < y:
if str((x * 10 + y)).__len__() == 2:
print(x * 10 + y)
for y in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]:
if x < y:
if str((x * 10 + y)).__len__() == 2:
print(x * 10 + y)
2019-07-01
(n代表第n项,例如第1项的和,则待入n 改变if的大于2)
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
x = 2 ** (n - 1)
sum += x
n += 1
print sum
sum = 0
x = 1
n = 1
while True:
if n > 20:
break
x = 2 ** (n - 1)
sum += x
n += 1
print sum
2019-07-01
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