Python for Data Science, AI, and Development
This course has these modules…
This course has these modules…
Tuples are an ordered sequence
Here is a Tuple “Ratings”
Tuples are written as comma-separated elements within parentheses
Tuples concatenation is possible
Tuple slicing is also possible
Tuples are immutable
If one want to manipulate tuples, they have to create a new tuple with the desired values
Tuples nesting (tuple containing another tuple) is also possible
Lists are also ordered in sequence
Here is a List “L”
A List is represented with square brackets
List is mutable
List can nest other lists and tuples
We can combine lists
List can be extended with extend() method
append() adds only one element to the List, if we append L.append([1,2,3,4]), the List “L” will be:
The method split() can convert the string into the List
The split() can be used with a delimiter we would like to split on as an argument
Multiple names referring to the same object is known as aliasing
You can convert a list into set
To add elements to the set, set.add('foo')
To remove an element, set.remove(‘foo’)
To check if an element is present in the set:
set1 & set2 or set1.intersection(set2)Union of the sets, contain elements of both the sets combined, set1.union(set2)
To find the difference of sets: