0% found this document useful (0 votes)
7 views

Python 3

Uploaded by

jamefik256
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Python 3

Uploaded by

jamefik256
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1. What is the difference between Single quoted string and double quoted string in python?

double quotes are used for string representation and single quotes are used for regular
expressions, dict keys . Hence both single quote and double quotes depict string in
python but it’s sometimes our need to use one type over the other.

2. What is the difference between immutable and mutable objects?

Mutable Objects-These can be changed after their creation. We can modify the contents of
these objects without changing their identity. ex-list, sets, dict.

Immutable objects-These cannot be changed after their creation. Any change to these
objects results in the creation of a new object. Ex-string, tuple, integer

3. What is the difference between list and tuple in python?

List is ordered collection elements, enclosed in square brackets [ ] and mutable means can
be changed after creation while tuple is ordered collection elements ,enclosed in
parenthesis ( ) and immutable means can not changed after creation.

4. What are the difference between a set and list in terms of Functionality and use cases?

SET-Unordered collection of unique elements. no duplicates allowed. Mutable, but the


elements must be immutable

List-Ordered collection of elements. duplicates allowed. Mutable, and allows indexing and
slicing.

5. How does a dictionary differ from a list in term of data storage and retrieval?

List-is ordered, index-based, and mutable, suitable for collections where order matters and
elements can be repeated.
Dictionary-is key-based, offering fast lookups and ideal for situations where each element
has a unique identifier (key).

You might also like