Chapter - 3 Python Programming Fundamentals-Part 2
Chapter - 3 Python Programming Fundamentals-Part 2
>> string[-9:]
'o, world!'
>>> string[:-8]
'Hello'
>>> string[:]
'Hello, world!'
Lists: List is also a sequence of values of any type.
Values in the list are called elements / items.
These are mutable and indexed/ordered. List is
enclosed in square brackets.
e.g. >>> Lst=[1,2,3]
>>> Lst[0]
output: 1
1. List
2. Set
3. Dictionary
An immutable variable change of value
will not happen in place. Modifying an
immutable variable will rebuild the
same variable.
1. int
2. float
3. decimal
4. complex
5. bool
6. string
7. tuple
Example
>>>x=5
Will create a value 5 referenced by x
x 5
>>>y=x
This statement will make y refer to 5 of x
>>> x=x+y
As x being integer (immutable type) has been rebuild.
In the statement, expression on RHS will result into value 10
and when this is assigned to LHS (x), x will rebuild to 10.