Midterm Exam Flashcards

(17 cards)

1
Q

Operator: //

A

floor division operator; rounds result down to the nearest whole number (even if decimal is over 5 DONT round up)

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

Operator: %

A

modulo operator: finds the remainder of a division

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

Operator: !=

A

not equal to operator

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

Character: /n

A

newline character; moves to the beginning of the next line before printing the next characters

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

Character: \

A

backslash; can break long lines of code into multiple lines without breaking logical line of code, also used as a way to ignore the next character (when using quotations in the print statement)

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

PEMDAS

A

parentheses, exponent, multiplication, division, addition, subtraction (MD and AS have same level of priority; in the same equation go left to right)

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

split()

A

prints a string into a list of substrings. default is to split by whitespace, but you can change the delimiter to split by commas, hyphens, etc. output = [‘word’, ‘word’, ‘word’]

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

isalnum()

A

checks if all the characters in the string are alphanumeric, meaning either letters or numbers
returns True if all characters are and is not empty
returns False if there are spaces, punctuation, symbols, or if it is empty

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

isalpha()

A

checks if all characters are alphabetic(letters)
only allows letters

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

isdigit()

A

checks if all characters are digits (0-9); no spaces, punctuation, etc

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

index()

A

used to find the lowest index (position) of a substring within a string. It returns the index where the substring is first found. If the substring is not found, it raises a ValueError. if there is something after the comma (“o” , 5) it starts from index 5 to find the first occurence

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

count()

A

Returns the number of times a specified substring occurs in the string. Optional start and end arguments can limit the search range

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

strip()

A

Returns a string where leading and trailing whitespace is removed. You can optionally specify characters to remove instead of whitespace.

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

.lower()

A

string method that returns a copy of the string with all uppercase characters converted to lowercase.

It does not change the original string (because strings are immutable).

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

.upper()

A

returns a copy of the string with all lowercase characters converted to uppercase.

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

find()

A

Searches for the specified substring and returns the lowest index where it’s found. Returns -1 if the substring is not found. Optional start and end arguments can limit the search range.

17
Q

.append()

A

adds a single item to the end of an existing list