[go: up one dir, main page]

0% found this document useful (0 votes)
19 views1 page

Dictionary

Uploaded by

POOJA DHAKANE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Dictionary

Uploaded by

POOJA DHAKANE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Dictionary

1. What is Dictionary?
Ans: In Python, Dictionary is a comma separated key-value pairs within curly
braces. It is unordered, Mutable.Each key in a dictionary is unique and is used to
access the associated value.

2. How to create Dictionary in Python?


Ans:
To create dictionary in Python use key-value pairs in curly braces.
Syntax:
Dict = {key1:val1, key2:val2, key3:val3}

For Example:

my_dict={'name':"Pooja",'age':24,'mobile_no.":9988776655,'city':"Pune"}

It will create dict in python

3.Create a Dict for 3 different cars


ans:
car_brands={
"Toyota":{"Model":"Camry","Year":2022,"Color":"Blue","Price":25000},
"Honda":{"Model":"Civic","Year":2021,"Color":"Red","Price":22000},
"Ford":{"Model":"Mustang","Year":2020,"Color":"Black","Price":30000}
}
print(car_brands)
#Output
#{'Toyota': {'Model': 'Camry', 'Year': 2022, 'Color': 'Blue', 'Price': 25000},
# 'Honda': {'Model': 'Civic', 'Year': 2021, 'Color': 'Red', 'Price': 22000},
# 'Ford': {'Model': 'Mustang', 'Year': 2020, 'Color': 'Black', 'Price': 30000}}

You might also like