sum = 0
x = 0
while True:
x = x + 1
if x > 100:
break
continue
sum = sum +x
x = x + 1
print sum
x = 0
while True:
x = x + 1
if x > 100:
break
continue
sum = sum +x
x = x + 1
print sum
2016-03-21
Py3.X源码文件默认使用utf-8编码,这就使得以下代码是合法的:
>>> 中国 = 'china'
>>>print(中国)
china
>>> 中国 = 'china'
>>>print(中国)
china
2016-03-20
L = [95.5, 85, 59,59]
print L[-1]
print L[-2]
print L[-3]
print L[-4]
print L[-1]
print L[-2]
print L[-3]
print L[-4]
2016-03-20
print 45678 + 0x12fd2
2) print 'Learn Python in imooc'
或者:
print "Learn Python in imooc"
3)print 100 < 99
print 0xff == 255
结果:
False
True
2) print 'Learn Python in imooc'
或者:
print "Learn Python in imooc"
3)print 100 < 99
print 0xff == 255
结果:
False
True
2016-03-20
Python 3.5.0 (v3.5.0:374f501f4567, Sep 12 2015, 11:00:19)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
SyntaxError: Missing parentheses in call to 'print'
>>> print r'''静夜思
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
SyntaxError: Missing parentheses in call to 'print'
>>> print r'''静夜思
2016-03-20
x1 = 1
d = 3
n = 100
x100 =x1+(n-1)*d
s =n*(x1+x100)/2
print s
s=14950
d = 3
n = 100
x100 =x1+(n-1)*d
s =n*(x1+x100)/2
print s
s=14950
2016-03-20