int x1 = 1;
int d = 3;
int s;
for (int i = 1; i < 100; i++) {
x1 += d;
}
s = ((x1 + 1)*100)/2;
}
result:14950
int d = 3;
int s;
for (int i = 1; i < 100; i++) {
x1 += d;
}
s = ((x1 + 1)*100)/2;
}
result:14950
2016-07-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,':',d[k]
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,':',d[k]
2016-07-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d.get('Adam')
print 'Lisa:',d.get('Lisa')
print 'Bart:',d.get('Bart')
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
print 'Adam:',d.get('Adam')
print 'Lisa:',d.get('Lisa')
print 'Bart:',d.get('Bart')
2016-07-08
sum = 0
x = 1
while (x < 100) && (x % 2 = 1):
sum += x
print sum
x = 1
while (x < 100) && (x % 2 = 1):
sum += x
print sum
2016-07-08
def firstCharUpper(s):
s1=s[:1]
s2=s[1:]
string=s1.upper()+s2.lower()
return string
print (firstCharUpper('hello'))
print (firstCharUpper('sunday'))
print (firstCharUpper('september'))
s1=s[:1]
s2=s[1:]
string=s1.upper()+s2.lower()
return string
print (firstCharUpper('hello'))
print (firstCharUpper('sunday'))
print (firstCharUpper('september'))
2016-07-08
L = list(range(1, 101))
print (L[:10])
print (L[2::3])
print (L[4:50:5])
print (L[:10])
print (L[2::3])
print (L[4:50:5])
2016-07-08
x1 = 1
d = 3
n = 100
x100 = x1 + d * (n - 1)
s = n * (x1 + x100)/2
print s
d = 3
n = 100
x100 = x1 + d * (n - 1)
s = n * (x1 + x100)/2
print s
2016-07-08
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print "%s: %d" % (key, d[key])
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for key in d:
print "%s: %d" % (key, d[key])
2016-07-08
def move(n,a,b,c):
if n==1:
print(a,'-->',c)
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
if n==1:
print(a,'-->',c)
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
2016-07-07
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.'''
复制即可通过。
2016-07-07