d = {
'Adam':95,
'Lisa':85,
'Bart':59
}
for key in d:
print (str(key) +str(':') + str(d[key]))
'Adam':95,
'Lisa':85,
'Bart':59
}
for key in d:
print (str(key) +str(':') + str(d[key]))
2018-04-18
import math
def quadratic_equation(a, b, c):
x1=math.sqrt(b*b/4.0/a/a-c/a)-(b/2.0/a)
x2=math.sqrt(b*b/4.0/a/a-c/a)*(-1)-(b/2.0/a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
x1=math.sqrt(b*b/4.0/a/a-c/a)-(b/2.0/a)
x2=math.sqrt(b*b/4.0/a/a-c/a)*(-1)-(b/2.0/a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2018-04-18
# -*- coding: utf-8 -*-
print '''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print '''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2018-04-18
运行成功,输出错误。什么意思,感觉格式一样啊!
# -*- coding: utf-8 -*-
print '''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
# -*- coding: utf-8 -*-
print '''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2018-04-18
def greet(l='world.'):
print 'Hello,',l
greet()
greet('Bart.')
print 'Hello,',l
greet()
greet('Bart.')
2018-04-18
print r'''"To be, or not to be": that is the question.\nWhether it's nobler in the mind to suffer.'''
2018-04-18
s = 'Python was started in 1989 by "Guido".\n Python is free and easy to learn.'
print s
print s
2018-04-18
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
2018-04-18
x1 = 1
d = 3
n = 100
x100 = x1+(100-1)*d
s = (x1+x100)*100/2
print s
d = 3
n = 100
x100 = x1+(100-1)*d
s = (x1+x100)*100/2
print s
2018-04-18
#input code
print "hello,python."
print "hello"+","+"python."
print "hello,python."
print "hello"+","+"python."
2018-04-18
#Enter a code
print 45678+0x12fd2
print 'Learn Python in imooc'
print 100<99
print 0xff == 255
print 45678+0x12fd2
print 'Learn Python in imooc'
print 100<99
print 0xff == 255
2018-04-18