print [x*100+y*10+z for x in range(1,10) for y in range(0,10) for z in range(1,10) if x==z]
2018-11-08
print [x+y+z for x in '123456789' for y in '0123456789' for z in '123456789' if x==z ]
2018-11-08
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for v in d.values():
sum+= v
print sum/4
sum = 0.0
for v in d.values():
sum+= v
print sum/4
2018-11-08
def firstCharUpper(s):
l=len(s)-1
h=s[:1].upper()
w=s[-l:]
return h+w
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
l=len(s)-1
h=s[:1].upper()
w=s[-l:]
return h+w
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2018-11-08
def firstCharUpper(s):
l=len(s)-1
h=s[:1].upper()
w=s[-l:]
print h,w
return
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
l=len(s)-1
h=s[:1].upper()
w=s[-l:]
print h,w
return
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2018-11-08
L = range(1, 101)
print L[0:10]
print L[2::3]
l=[]
for x in L[4::5]:
if x <= 50:
l.append(x)
print l
print L[0:10]
print L[2::3]
l=[]
for x in L[4::5]:
if x <= 50:
l.append(x)
print l
2018-11-08
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print x[0],":",x[1]
for x in s:
print x[0],":",x[1]
2018-11-07
months = set(['Jan','Feb'])
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
x1 = 'Feb'
x2 = 'Sun'
if x1 in months:
print 'x1: ok'
else:
print 'x1: error'
if x2 in months:
print 'x2: ok'
else:
print 'x2: error'
2018-11-07