Exercise 37: Symbol Review

and
del
from
not
while
as
elif
global
or
with
assert # http://stackoverflow.com/questions/5142418/what-is-the-use-of-assert-in-python 

The assert statement/function exists in mostly every other programming language out there. When you do...

assert a_condition
... you're telling the program to test that condition, and trigger an error if the condition is false.

In Python, it's roughly equivalent to this:

if not condition:
    raise AssertionError()
Try it in the Python shell:

>>> assert True
>>> assert False
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError
Assertions can include an optional message, and you can disable them when you're done debugging. See here for the relevant documentation.

 

else
if
pass
yield
break
except
import
print
class
exec

in
raise
continue
finally
is
return
def
for
lambda
try

 

True
False
None
strings
numbers
floats
lists

 

\\
\'
\"
\a
\b
\f
\n
\r
\t
\v

 

%d
%i
%o
%u
%x
%X
%e
%E
%f
%F
%g
%G
%c
%r
%s
%%

 

+-*
**
/
//
%<>
<=
>=
==
!=
<>
( )
[ ]
{ }
;
+=
-=
*=
/=
//=
%=
**=

posted @ 2014-10-26 10:36  林中细雨  阅读(126)  评论(0编辑  收藏  举报