my_list = [1, 2, 3, 4, 5]
print(my_list[1:3])
List slicing [1:3] returns elements from index 1 (inclusive) to index 3 (exclusive), which are elements at positions 1 and 2.
pop() removes and returns the last element (or element at specified index). remove() only removes value, doesn't return it.
Square brackets [] create a list object. Lists in Python can contain elements of different data types (heterogeneous).
In Python, the string data type is represented as 'str', not 'string'. 'string' is not a built-in data type.
my_list = [1, 2, 3]
my_list.append(4)
print(len(my_list))
append() adds one element to the list. Initial length is 3, after append(4) it becomes 4.
x += 3 is equivalent to x = x + 3. Starting with x=5, after adding 3, x becomes 8.
The 'in' operator checks if 'a' is a substring of 'banana'. It is present (multiple times), so it returns True.
This is a ternary conditional expression. Since 5 > 3 is True, the expression evaluates to 10 (the value before 'if').
The string 'Python' has 6 characters: P-y-t-h-o-n. len() returns the number of characters in a string.
In Python 3, the division operator (/) always returns a float, regardless of whether the operands are integers. 5 / 2 = 2.5, which is a float.