Data Types Flashcards
Strings are mutable or immutable?
immutable
Lists are mutable or immutable?
mutable
Tuples are mutable or immutable?
immtable
in string indexing, str[-1] refers to what?
the las character
what is the use of List.append()?
add elements to list
what is diffrent between list.append() and list.insert() ?
append() method only works for addition of elements at the end of the List, for addition of element at the desired position, insert() method is used. Unlike append() which takes only one argument, insert() method requires two arguments(position, value).
what is the use of List.extend()?
used to add multiple elements at the same time at the end of the list
how sums up list number?
sum(list)
what is Set ?
Set is an unordered collection of data type that is iterable, mutable and has no duplicate elements.
what is major adavantage f using a set over list?
The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for checking whether a specific element is contained in the set , removing duplicates from a sequence, and computing mathematical operations such as intersection, union, difference, and symmetric difference
what is the diffrence between array and list
If you create arrays using the array module, all elements of the array must be of the same type.
what is Dictionary?
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element
what is advantage of key:value pair in dictaionary?
Dictionary holds key:value pair. Key value is provided in the dictionary to make it more optimized.