Vocabulary and Symbols Flashcards

1
Q

break

A

while True: break

stop loop right now

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

class

A

class Person(object)

define a class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

assert

A

assert False, “Error!”

assert (ensure) that something is true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

continue

A

while True: continue

don’t process more of the loop, do it again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

elif

A

else:

if:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

except

A

except ValueError, e: print e

if an exception happens, do this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

exec

A

exec ‘print “hello” ‘

run as a string in Python

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

finally

A

finally: pass

exceptions or not, finally do this no matter what

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

from

A

x from y

import a module into this one to use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

global

A

global x

declare that you want a global variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

is

A

1 is 1 == True

like == to test equality

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

lambda

A

s = lambda y: y ** y; s(3)

create a short, anonymous function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

not

A

not True == False

logical not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

or

A

True or False == True

logical or

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

pass

A

def empty( ): pass

this block is empty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

raise

A

raise ValueError(“No”)

raise an exception when things go wrong

17
Q

return

A

def X( ): return Y

exit the function with a return value

18
Q

try

A

try: pass

try this block, and if exception, go to “except”

19
Q

yield

A

def X( ): yield Y; X( ).next( )

pause here and return to caller