Symbols Flashcards

1
Q

and

A

Logical and

Example:

True and False == False

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

as

A

Part of the with -as statement.

Example:

with X as Y: pass

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

assert

A

Assert (ensure) that something is true

Example:

assert False, “Error!”

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

break

A

stop this loop right now

Example:

While True: break

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

class

A

Define a class

Example:

class Person(object)

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

contiunue

A

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

Example:

while True: continue

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

def

A

Define a function

Example:

def X(): pass

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

del

A

Delete from a dictionary

Example:

del X(Y)

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

elif

A

Else if condition

Example:

if: X; elif: Y; else: J

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

else

A

Else condition

Example:

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

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

except

A

If an exception happens, do this

Example:

except ValueError, e: print(e)

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

exec

A

Run a string as Python

Example:

|exec ‘print(“hello”) ‘

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

finally

A

Exceptions or not, finally do this no matter what

Example:

finally: pass

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

for

A

loop over a colletion of things

Example:

for X in Y: pass

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

from

A

Import specific parts of a module

Example:

from X import Y

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

global

A

Declare that you want a global variable

Example:

global X

17
Q

if

A

If condition

Example:

if: X; elif: Y; else: J

18
Q

import

A

Import a module into this one to use

Example:

import os

19
Q

in

A

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

Example:

for X in Y: pass also 1 in (1) == True

20
Q

is

A

Like == to test equality

Example:

1 is 1 == True

21
Q

lambda

A

Create a short anonymous function

Example:

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

22
Q

not

A

Logical not

Example:

not True == False

23
Q

or

A

Logical or

Example:

True or False == True

24
Q

pass

A

This block is empty

Example:

def empty(): pass

25
Q

print

A

Print this string

Example:

print(‘this string’)

26
Q

raise

A

Raise an exception when the strings go wrong

Example:

raise ValueError(“No”)

27
Q

return

A

Exit the function with a return value

Example:

def X(): return Y

28
Q

try

A

Try this block, and if exception, go to except.

Example:

try: pass

29
Q

while

A

While loop.

Example: while X: pass

30
Q

with

A

With an expression as a variable do.

Example: with X as Y: pass

31
Q

yield

A

Pause here and return to caller.

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