PythonTheHardWay Flashcards

(114 cards)

1
Q

print “something”

A

print statement (of something in quotes)

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

#

A

pound character used to comment or disable parts of code

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

+

A

plus symbol. used to add numbers or concatenate strings

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

-

A

minus symbol. used in subtraction

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

/

A

slash symbol. used in division

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

*

A

asterisk symbol. used in multiplication

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

%

A

modulus symbol. used to get remainder in division

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

less-than symbol.

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

>

A

greater-than symbol

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

less-than-or-equal symbol

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

> =

A

greater-than-or-equal symbol

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

=

A

single-equal. assigns the value on the right to a variable on the left

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

==

A

double-equal. tests if two things have the same value

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

%s

A

string formatter

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

%d

A

number formatter

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

%r

A

raw data formatter. displays the raw data of a variable.

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

\n

A

newline symbol

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

\t

A

tab symbol

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

\

A

escape character

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

raw_input()

A

reads a line from input and converts to string

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

argv

A

the argument variable. holds the arguments passed into a script from the command line.

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

import

A

imports any Python source file as a module

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

open()

A

open a file, e.g. txt = open(filename).

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

read()

A

read the contents of a file, e.g. txt.read()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
close()
close a previously opened file
26
write()
write to an open file, e.g. f.write('some text')
27
truncate()
truncate the file size
28
*args
allows you to pass a non-keyworded variable argument list to a function
29
seek()
set the position of the read/write pointer within a file
30
readline()
reads one entire line from the file
31
not False
True
32
not True
False
33
True or False
True
34
True or True
True
35
False or True
True
36
False or False
False
37
True and False
False
38
True and True
True
39
False and True
False
40
False and False
False
41
not (True or False)
False
42
not (True or True)
False
43
not (False or True)
False
44
not (False or False)
True
45
not (True and False)
True
46
not (True and True)
False
47
not (False and True)
True
48
not (False and False)
True
49
1 != 0
True
50
1 != 1
False
51
0 != 1
True
52
0 != 0
False
53
1 == 0
False
54
1 == 1
True
55
0 == 1
False
56
0 == 0
True
57
as
part of the with-as statement
58
assert
ensure something is true
59
break
stop this loop right now (while True: break)
60
class
define a class, e.g. class Person(obj)
61
continue
don't process more of a loop, do it again (while True: continue)
62
def
define/declare a function
63
del
delete from a dictionary, e.g. del X[Y]
64
elif
else if condition
65
else
else condition
66
except
if an exception occurs, do this (except ValueError, e: print e)
67
exec
run a string as Python
68
finally
exceptions or not, finally do this no matter what
69
for
loop over a collection of things
70
from
import specific parts of a module
71
global
declare a global variable
72
if
if condition
73
in
part of a for-loop
74
is
like == to test equality
75
lambda
create a short anonymous function
76
pass
this block is empty
77
raise
raise an exception when things go wrong
78
return
exit the function with a return value
79
try
test this block and if exception, go to except
80
while
while loop
81
with
with an expression as a variable do
82
yield
pause here and return to caller
83
None
Represents "nothing" or "no value"
84
string
stores textual information
85
int
stores numbers
86
float
stores decimals
87
list
stores a collection of things
88
dict
stores a key=value mapping of things
89
%i
same as %d
90
%o
octal number
91
%u
unsigned decimal
92
%x
hexadecimal lowercase
93
%X
hexadecimal uppercase
94
%e
exponential notation, lowercase 'e'
95
%E
exponential notation, uppercase "E"
96
%f
floating point real number
97
%F
same as %f
98
%g
Either %f or %e, whichever is shorter
99
%G
same as %g but uppercase
100
%c
character format
101
%%
a percent sign
102
**
power of
103
//
floor division (2 // 4.0 == 0.5)
104
not equal
105
[ ]
list brackets
106
{ }
dict brackets
107
@
decorator
108
+=
add and assign
109
-=
subtract and assign
110
*=
multiply and assign
111
/=
divide and assign
112
//=
floor divide and assign
113
%=
modulus assign
114
**=
power assign (x **= 2)