999 Python Super Tips (28 → 34)
999 Python Super Tips (28 → 34)

999 Python Super Tips (28 → 34)

Tags
Published
November 13, 2022
Author
Mai The Dung

28. Difference between == and “is”

“is” checks whether 2 variables are pointing to the same object in memory.
“==” compares the equality of values that these 2 objects hold.
notion image

29. Check whether a string starts with a particular character without using the index 0

notion image

30. Find the unique id of a variable using id()

notion image

31. Integers, floats, strings, booleans, and tuples are immutable

When we assign a variable to an immutable type such as integers, floats, strings, booleans, and tuples, then this variable points to an object in memory.
In case we assign another to that variable another value, the original object is still in memory, but the variable pointing to it is lost.
notion image

32. Strings and tuples are immutable

notion image

33. Lists, sets, and dictionaries are mutable

This means that we can change the object without losing binding to it.
notion image

34. You can turn a set into an immutable set

notion image