Python Flashcards

1
Q

inline if

A

print a if b else 0

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

how to write inline dictionary init or update. element

A

hash_map[char] = hash_map[char] + 1 if char in hash_map else 1

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

how to get the values of dictionary?

A

mp.values(), and it return a list of all the values.

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

!= vs not

A

not is a logic operation that convert the bool value
!= check if left not equal to right

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