Symbol Review Flashcards

1
Q

and

A

Logical and. (e.g. 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. (e.g. 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. (e.g. 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. (e.g. 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. (e.g. class Person(object))

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

continue

A

Don’t process more of the loop, do it again. (e.g. 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. (e.g. def X(): pass)

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

del

A

Delete from dictionary. (e.g. 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. (e.g. 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. (e.g. 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. (e.g. 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. (e.g. 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. (e.g. finally: pass)

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

for

A

Loop over a collection of things. (e.g. 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. (e.g. 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. (e.g. global X)

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

if

A

If condition. (e.g. if: X; elif: Y; else: J)

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

import

A

Import a module to use. (e.g. import os)

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

in

A

Part of for-loops. Also a test of X in Y. (e.g. for X in Y: pass, 1 in [1] == True)

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

is

A

Like == to test equality (e.g. 1 is 1 == True)

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

lambda

A

Create a short anonymous function. (e.g. s = lambda y: y ** y; s(3)

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

not

A

Logical not. (e.g. not True == False)

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

or

A

Logical or. (e.g. True or False == True)

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

pass

A

This block is empty. (e.g. def empty(): pass)

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

print

A

Print this string. (e.g. print(‘this string’))

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

raise

A

Raise an exception when things go wrong. (e.g. raise ValueError(“No”)

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

return

A

Exit the function with a return value. (e.g. def X(): return Y)

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

try

A

Try this block, and if exception, go to except. (e.g. try: pass)

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

while

A

While loop (e.g. while X: pass)

30
Q

with

A

With an expression as a variable do. (e.g. with X as Y: pass)

31
Q

yield

A

Pause here and return to caller. (e.g. def X(): yield Y; X().next())

32
Q

True

A

True Boolean value.

33
Q

False

A

False Boolean value.

34
Q

None

A

Represents “nothing” or “no value”. (e.g. x = None)

35
Q

bytes

A

Stores bytes, maybe of text, PNG etc files. (e.g. x = b”hello”)

36
Q

strings

A

Stores textual information. (e.g. x = “hello”)

37
Q

numbers

A

Stores integers. (e.g. i = 100)

38
Q

floats

A

Stores decimals. (e.g. i = 10.389)

39
Q

lists

A

Stores a list of things. (e.g. k = [1, 2, 3, 4]

40
Q

dicts

A

Stores a key=value mapping of things. (e.g. e = {‘x’: 1, ‘y’:2]

41
Q

\

A

Blackslash

42
Q

'

A

Single-quote

43
Q

"

A

Double-quote

44
Q

\a

A

Bell

45
Q

\b

A

Backspace

46
Q

\f

A

Formfeed

47
Q

\n

A

Newline

48
Q

\r

A

Carriage

49
Q

\t

A

Tab

50
Q

\v

A

Vertical tab

51
Q

%d

A

Decimal integers (not floating point) (e.g. “%d” % 45 == ‘45’)

52
Q

%i

A

Decimal integers (not floating point) (e.g. “%i” % 45 == ‘45’)

53
Q

%o

A

Octal number (e.g. “%o” % 1000 == ‘1750’)

54
Q

%u

A

Unsigned decimal (e.g. “%u” % -1000 = ‘-1000’)

55
Q

%x

A

Hexadecimal lowercase (e.g. “%x” % 1000 == ‘3e8’)

56
Q

%X

A

Hexadecimal uppercase (e.g. “%X” % 1000 == ‘3E8’)

57
Q

%e

A

Exponential notation, lowercase “e” (e.g. “%e” % 1000 == ‘1.000000e+03’)

58
Q

%E

A

Exponential notation, uppercase “e” (e.g. “%E” % 1000 == ‘1.000000E+03’)

59
Q

%f

A

Floating point real number (e.g. %f % 10.34 == ‘10.340000’)

60
Q

%F

A

Floating point real number (e.g. %F % 10.34 == ‘10.340000’)

61
Q

%g

A

Either %f or %e, whichever is shorter (e.g. “%g” % 10.34 == ‘10.34’)

62
Q

%G

A

Either %F or %E, whichever is shorter (e.g. “%g” % 10.34 == ‘10.34’)

63
Q

%c

A

Character format (e.g. “%c” % 34 == ‘ ‘’ ‘)

64
Q

%r

A

Repr format (debugging format) (e.g. “%r” % int == “”)

65
Q

%s

A

String format (e.g. “%s there” % ‘hi’ == ‘hi there’)

66
Q

%%

A

A percent sign (e.g. “%g%%” % 10.34 == ‘10.34%’)

67
Q

//

A

Floor division (e.g. 2 // 4 == 0)

68
Q

%

A

String interpolate or modulus (e.g. 2 % 4 == 2)

69
Q

( )

A

Parentheses

70
Q

[ ]

A

List brackets

71
Q

{ }

A

Dict curly braces

72
Q

@

A

At (decorators) (e.g. @classmethod)