Uploaded by Suruz Ahammed

MidTerm Preparation

advertisement
What is Tuple? How literals of type tuple are written?Give example?
A tuple is a collection which is ordered and unchangeable. In Python tuples are
written with round brackets.
thistuple = ("apple", "banana", "cherry")
What is List?How list differ form tuples?
List is a collection which is ordered and changeable. Allows duplicate
members
List is mutable and tuples is
and immutable is memory usage
create a variable, some fixed
list, more memory is assigned
immutable. The main difference between mutable
when you are trying to append an item. When you
memory is assigned to the variable. If it is a
than actually used
How to slice a list in Python?
We can slice a list using python’s slicing operator which has following
syntax : [start : stop : steps]
Download