Keywords Flashcards

0
Q

del

A

Delete from dictionary.

…del X[Y]

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

and

A

Logical and.

…True and False == False

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

from

A

Importing specific parts of a module

…from x import Y

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

not

A

Logical not

…not True == False

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

while

A

while loop, keeps running so long as the test at the top is True

…while X: pass

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

as

A

Part of the with-as statement.

…with X as Y: pass

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

elif

A

Else if condition.

…if: X; Elif: Y; else: J

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

global

A

Declare that you want a global variable

…global X

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

or

A

Logical or

..True or False == True

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

with

A

With an expression as a variable do.

…with X as Y: pass

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

assert

A

Assert (ensure) that something is true.

…assert False, “Error!”

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

else

A

Else condition

…if: X; elif: Y; else: J

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

if

A

If condition.

…if: X; elif: Y; else: J

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

pass

A

This block is empty.

…def empty(): pass

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

yield

A

Pause here and return to caller.

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

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

break

A

Stop this loop right now.

…while True: break

16
Q

except

A

If an exception happens, do this.

…except ValueError, e: print(e)

17
Q

import

A

Import a module into this one to use.

…import os

18
Q

print

A

Print this string.

…print(‘this string’)

19
Q

class

A

Define a class.

…class Person(object)

20
Q

exec

A

Run a string as Python.

…exec ‘print(“hello”)’

21
Q

in

A

Part of for-loops. Also a test of X in Y.

…for X in Y: pass
…1 in [1] == True

22
Q

raise

A

Raise an exception when things go wrong.

…raise ValueError(“No”)

23
Q

continue

A

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

…while True: continue

24
Q

finally

A

Exceptions or not, finally do this no matter what.

..finally: pass

25
Q

is

A

Like == to test equality

…1 is 1 == True

26
Q

return

A

Exit the function with a return value.

…def X(): return Y

27
Q

def

A

Define a function.

…def X(): pass

28
Q

for

A

Loop over a collection of things.

…for X in Y: pass

29
Q

lambda

A

Create a short anonymous function.

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

30
Q

try

A

Try this block, and if exception, go to except

…try: pass