Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Coding language

Rating
-
Sold
-
Pages
12
Uploaded on
20-09-2025
Written in
2025/2026

This is a coding language notes

Institution
Course

Content preview

5.1CONCEPT(MUTABLE)
Everything in Python is an object. All objects in Python can be either mutable or immutable.
An object's mutability is determined by its type. Some of these objects like lists and dictionaries are
mutable, means their content can be changed.
In Python, immutable objects are those whose value cannot be changed in place after assignment or
initialization. A tuple is an immutable linear data structure. Thus, in contrast to lists, once atuple is
defined, it cannot be altered or changed.
Adictionary is a collection which is unordered, changeable and indexed. In Python, dictionaries are
written with curly brackets, and they have keys and values.
Dictionaries are optimized to retrieve values when the key is known.
Dictionaries are Python's implementation of a data structure that is more generally known as an
Associative Array. A dictionary consists of a collection of key-value pairs. Each key-value pair maps
the key toits associated value.
Comparison of Dictionaries and Lists:
Both are mutable.
Both are dynamic. They can grow and shrink as needed.
Both can be nested. A list can contain another list. A dictionary can contain another dictionary. A
dictionary can also contain a list, and vice versa.
List elements are accessed by their position in the list, via indexing while Dictionary elenments are
accessed via keys.
5.1|

, Python Programming (BCA Sclence: VI) Python Dition

CREATING AND ACCESSING VALUES IN ADICTIONARY
values.
As we know, dictionary is delete and update old
mutable, we can add new valuesand
5.2.1 Creation of Dictionary
Creating a dictionary is as simple as placing items inside curly braces ) separated by comma. An iten
has a key and the corresponding value expressed as a pair, key: value.
Each key is separated from its value by a coBon (), the items are separated by commas, and the whole
,eniosed in curly braces. An empty dictionary without any items is Written Withjust two CUrl.
braces, like this: ).
y uuque within a dictionary while values may not be.The values of a dictionary can be of ah
ype, but the keys must be of an immtable data tvpe such as strings, numbers, or tuples.
Syntax:
dictionary name = {
<key>: <value>,
<key>: <value>,




<key>: <value>

Or

dictionary_name = dict ([
(<key>, <value>),
(<key>, <value),



(<key>, <value>)

where dict is built-in function.
Example: -
# empty dictionary with name dict
dict =

# dictionary with integer keys
dict = {1: 'apple', 2: 'orange'}
# dictionary with mixed keys
dict = {'name': 'abc', I: (2, 4, 3]}
# using dict()
dict = dict({1:'apple', 2:'orange'})
# from sequence having each item as a pair
dict = dict ([(1, 'apple'), (2, 'orange')])
5.2

Written for

Course

Document information

Uploaded on
September 20, 2025
Number of pages
12
Written in
2025/2026
Type
OTHER
Person
Unknown

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
adityapansare6

Get to know the seller

Seller avatar
adityapansare6 Sangamner college Sangamner
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
7 months
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions