Python Flashcards

(44 cards)

1
Q

\

A

Backslash. Prints one backslash.

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

'

A

Single quote. Prints a single quote.

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

"

A

Double quote. Prints a single double quote.

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

\a

A

Bell. Sounds the system bell.

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

\n

A

Newline. Moves the cursor to the beginning of next line.

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

\t

A

Horizontal tab. Moves cursor forward one tab stop.

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

+

A

Addition. Combines two strings or adds two integers.

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

-

A

Subtraction.

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

*

A

Multiplication. Multiplies a string or integer.

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

/

A

Division (true).

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

//

A

Division (integer). Divides without a remainder.

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

%

A

Modulus. Gives just the remainder.

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

input ( )

A

Gets text from the user. Returns the answer as a string.

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

upper ( )

A

Returns uppercase version of the string.

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

lower ( )

A

Returns lowercase version of the string.

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

swapcase ( )

A

Returns a new string where the case of each letter is switched.

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

capitalize ( )

A

Returns a new string where the first letter is capitalized and the rest are lowercase.

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

title ( )

A

Returns a new string where the first letter of each word is capitalized and all others are lowercase.

19
Q

strip ( )

A

Returns a string where all the white space (tabs, spaces, and newlines) at the beginning and end are removed.

20
Q

replace(old, new [,max])

A

Returns a string where occurrences of the string ‘old’ are replaced with the string ‘new’. The optional ‘max’ limits the number of replacements.

21
Q

*=

A

x *= 5 is equivalent to x = x * 5

22
Q

/=

A

x /= 5 is equivalent to x = x / 5

23
Q

%=

A

x %= 5 is equivalent to x = x % 5

24
Q

+=

A

x += 5 is equivalent to x = x + 5

25
-=
x -= is equivalent to x = x - 5
26
==
equal to
27
!=
not equal to
28
>
greater than
29
<
less than
30
>=
greater than or equal to
31
<=
less than or equal to
32
append(value)
adds the value to the end of a list
33
sort( )
Sorts the elements of a list. Smallest value first. Optionally you can pass a Boolean value to the parameter 'reverse'. If you pass True, the list will be sorted with the largest value first. ex: sort(reverse=True)
34
reverse( )
Reverses the order of a list
35
count(value)
Returns the number of occurrences of 'value'
36
index(value)
Returns the first position number of where 'value' occurs
37
insert( i, value)
inserts 'value' at position 'i'
38
pop([i])
Returns value at position 'i' and removes value from the list. Providing the position number 'i' is optional. Without it, the last element in the list is removed and returned
39
remove(value)
Removes the first occurrence of 'value' from the list
40
del list[position:range]
Deletes a value or range of values based on their position number
41
get(key, [default])
Returns the value of "key". If key doesn't exist, then the optional "default" is returned. If "key " doesn't exist and "default" isn't specified, then None is returned.
42
keys( )
Returns a view of all the keys in a dictionary.
43
values( )
Returns a view of all the values in a dictionary.
44
items( )
Returns a view of all the items in a dictionary. Each item is a two-element tuple, where the first element is a key and the second element is the key's value.