d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum1 = 0.0
for x in d.itervalues():
sum1+=x
print sum1/len(d.values())
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
print float(sum(d.values()))/len(d.values())
sum1 = 0.0
for x in d.itervalues():
sum1+=x
print sum1/len(d.values())
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
print float(sum(d.values()))/len(d.values())
2019-04-18
def average(*args):
if float(len(args)) == 0 :
return float(len(args))
return sum(args)/float(len(args))
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if float(len(args)) == 0 :
return float(len(args))
return sum(args)/float(len(args))
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-04-18
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.'''
2019-04-18
print 'Python was started in 1989 by \"Guido\".'
print 'Python is free and easy to learn.'
print 'Python is free and easy to learn.'
2019-04-18
sum = 0
n = 1
a = 1
while n <= 100:
sum +=a
a=a+3
n=n+1
print(sum)
n = 1
a = 1
while n <= 100:
sum +=a
a=a+3
n=n+1
print(sum)
2019-04-18
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k,v in d.items():
sum += v
print k,':',v
print 'average:',sum / len(d.items())
sum = 0.0
for k,v in d.items():
sum += v
print k,':',v
print 'average:',sum / len(d.items())
2019-04-18
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for x in d.itervalues():
sum += x
a = sum / len(d.values())
print a
sum = 0.0
for x in d.itervalues():
sum += x
a = sum / len(d.values())
print a
2019-04-18
d = {
95:'Adam',85:'Lisa',59:'Bart'
}
print d
95:'Adam',85:'Lisa',59:'Bart'
}
print d
2019-04-18