d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for x in d.values():
sum = sum + x
print sum / len(d.values())
sum = 0.0
for x in d.values():
sum = sum + x
print sum / len(d.values())
2015-08-30
def firstCharUpper(s):
return s[0:1].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0:1].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-08-30
def average(*args):
sum = 0.0
n = 0
if len(args) == 0:
return sum
else:
for x in args:
sum = sum + x
n = n + 1
return (sum / n)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0.0
n = 0
if len(args) == 0:
return sum
else:
for x in args:
sum = sum + x
n = n + 1
return (sum / n)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2015-08-30
x1 = 1
d = 3
n = 100
x100 = x1 + (n - 1) * d
s = (x1 + x100) * n / 2
print s
d = 3
n = 100
x100 = x1 + (n - 1) * d
s = (x1 + x100) * n / 2
print s
2015-08-30
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]
2015-08-29