Symbol Review Flashcards

(72 cards)

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
print
Print this string. (e.g. print('this string'))
26
raise
Raise an exception when things go wrong. (e.g. raise ValueError("No")
27
return
Exit the function with a return value. (e.g. def X(): return Y)
28
try
Try this block, and if exception, go to except. (e.g. try: pass)
29
while
While loop (e.g. while X: pass)
30
with
With an expression as a variable do. (e.g. with X as Y: pass)
31
yield
Pause here and return to caller. (e.g. def X(): yield Y; X().next())
32
True
True Boolean value.
33
False
False Boolean value.
34
None
Represents "nothing" or "no value". (e.g. x = None)
35
bytes
Stores bytes, maybe of text, PNG etc files. (e.g. x = b"hello")
36
strings
Stores textual information. (e.g. x = "hello")
37
numbers
Stores integers. (e.g. i = 100)
38
floats
Stores decimals. (e.g. i = 10.389)
39
lists
Stores a list of things. (e.g. k = [1, 2, 3, 4]
40
dicts
Stores a key=value mapping of things. (e.g. e = {'x': 1, 'y':2]
41
\\
Blackslash
42
\'
Single-quote
43
\"
Double-quote
44
\a
Bell
45
\b
Backspace
46
\f
Formfeed
47
\n
Newline
48
\r
Carriage
49
\t
Tab
50
\v
Vertical tab
51
%d
Decimal integers (not floating point) (e.g. "%d" % 45 == '45')
52
%i
Decimal integers (not floating point) (e.g. "%i" % 45 == '45')
53
%o
Octal number (e.g. "%o" % 1000 == '1750')
54
%u
Unsigned decimal (e.g. "%u" % -1000 = '-1000')
55
%x
Hexadecimal lowercase (e.g. "%x" % 1000 == '3e8')
56
%X
Hexadecimal uppercase (e.g. "%X" % 1000 == '3E8')
57
%e
Exponential notation, lowercase "e" (e.g. "%e" % 1000 == '1.000000e+03')
58
%E
Exponential notation, uppercase "e" (e.g. "%E" % 1000 == '1.000000E+03')
59
%f
Floating point real number (e.g. %f % 10.34 == '10.340000')
60
%F
Floating point real number (e.g. %F % 10.34 == '10.340000')
61
%g
Either %f or %e, whichever is shorter (e.g. "%g" % 10.34 == '10.34')
62
%G
Either %F or %E, whichever is shorter (e.g. "%g" % 10.34 == '10.34')
63
%c
Character format (e.g. "%c" % 34 == ' '' ')
64
%r
Repr format (debugging format) (e.g. "%r" % int == "")
65
%s
String format (e.g. "%s there" % 'hi' == 'hi there')
66
%%
A percent sign (e.g. "%g%%" % 10.34 == '10.34%')
67
//
Floor division (e.g. 2 // 4 == 0)
68
%
String interpolate or modulus (e.g. 2 % 4 == 2)
69
( )
Parentheses
70
[ ]
List brackets
71
{ }
Dict curly braces
72
@
At (decorators) (e.g. @classmethod)