Python Flashcards

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
Q

-=

A

x -= is equivalent to x = x - 5

26
Q

==

A

equal to

27
Q

!=

A

not equal to

28
Q

>

A

greater than

29
Q

<

A

less than

30
Q

> =

A

greater than or equal to

31
Q

<=

A

less than or equal to

32
Q

append(value)

A

adds the value to the end of a list

33
Q

sort( )

A

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
Q

reverse( )

A

Reverses the order of a list

35
Q

count(value)

A

Returns the number of occurrences of ‘value’

36
Q

index(value)

A

Returns the first position number of where ‘value’ occurs

37
Q

insert( i, value)

A

inserts ‘value’ at position ‘i’

38
Q

pop([i])

A

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
Q

remove(value)

A

Removes the first occurrence of ‘value’ from the list

40
Q

del list[position:range]

A

Deletes a value or range of values based on their position number

41
Q

get(key, [default])

A

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
Q

keys( )

A

Returns a view of all the keys in a dictionary.

43
Q

values( )

A

Returns a view of all the values in a dictionary.

44
Q

items( )

A

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.