PythonTheHardWay Flashcards

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
Q

close()

A

close a previously opened file

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

write()

A

write to an open file, e.g. f.write(‘some text’)

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

truncate()

A

truncate the file size

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

*args

A

allows you to pass a non-keyworded variable argument list to a function

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

seek()

A

set the position of the read/write pointer within a file

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

readline()

A

reads one entire line from the file

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

not False

A

True

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

not True

A

False

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

True or False

A

True

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

True or True

A

True

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

False or True

A

True

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

False or False

A

False

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

True and False

A

False

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

True and True

A

True

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

False and True

A

False

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

False and False

A

False

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

not (True or False)

A

False

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

not (True or True)

A

False

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

not (False or True)

A

False

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

not (False or False)

A

True

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

not (True and False)

A

True

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

not (True and True)

A

False

47
Q

not (False and True)

A

True

48
Q

not (False and False)

A

True

49
Q

1 != 0

A

True

50
Q

1 != 1

A

False

51
Q

0 != 1

A

True

52
Q

0 != 0

A

False

53
Q

1 == 0

A

False

54
Q

1 == 1

A

True

55
Q

0 == 1

A

False

56
Q

0 == 0

A

True

57
Q

as

A

part of the with-as statement

58
Q

assert

A

ensure something is true

59
Q

break

A

stop this loop right now (while True: break)

60
Q

class

A

define a class, e.g. class Person(obj)

61
Q

continue

A

don’t process more of a loop, do it again (while True: continue)

62
Q

def

A

define/declare a function

63
Q

del

A

delete from a dictionary, e.g. del X[Y]

64
Q

elif

A

else if condition

65
Q

else

A

else condition

66
Q

except

A

if an exception occurs, do this (except ValueError, e: print e)

67
Q

exec

A

run a string as Python

68
Q

finally

A

exceptions or not, finally do this no matter what

69
Q

for

A

loop over a collection of things

70
Q

from

A

import specific parts of a module

71
Q

global

A

declare a global variable

72
Q

if

A

if condition

73
Q

in

A

part of a for-loop

74
Q

is

A

like == to test equality

75
Q

lambda

A

create a short anonymous function

76
Q

pass

A

this block is empty

77
Q

raise

A

raise an exception when things go wrong

78
Q

return

A

exit the function with a return value

79
Q

try

A

test this block and if exception, go to except

80
Q

while

A

while loop

81
Q

with

A

with an expression as a variable do

82
Q

yield

A

pause here and return to caller

83
Q

None

A

Represents “nothing” or “no value”

84
Q

string

A

stores textual information

85
Q

int

A

stores numbers

86
Q

float

A

stores decimals

87
Q

list

A

stores a collection of things

88
Q

dict

A

stores a key=value mapping of things

89
Q

%i

A

same as %d

90
Q

%o

A

octal number

91
Q

%u

A

unsigned decimal

92
Q

%x

A

hexadecimal lowercase

93
Q

%X

A

hexadecimal uppercase

94
Q

%e

A

exponential notation, lowercase ‘e’

95
Q

%E

A

exponential notation, uppercase “E”

96
Q

%f

A

floating point real number

97
Q

%F

A

same as %f

98
Q

%g

A

Either %f or %e, whichever is shorter

99
Q

%G

A

same as %g but uppercase

100
Q

%c

A

character format

101
Q

%%

A

a percent sign

102
Q

**

A

power of

103
Q

//

A

floor division (2 // 4.0 == 0.5)

104
Q
A

not equal

105
Q

[ ]

A

list brackets

106
Q

{ }

A

dict brackets

107
Q

@

A

decorator

108
Q

+=

A

add and assign

109
Q

-=

A

subtract and assign

110
Q

*=

A

multiply and assign

111
Q

/=

A

divide and assign

112
Q

//=

A

floor divide and assign

113
Q

%=

A

modulus assign

114
Q

**=

A

power assign (x **= 2)