Dictionary in Python
DICTIONARY:-
- Dictionary object can be created by using Curly Bracket { } or by calling dictionary function.
- Dictionary object represent the data in the form of key value formate.
- Each key value pair of dictionary is technology known as iteam.
- Duplicate keys are not allowed but value can be duplicated.
- Dictionary are mutable.
- Dictionary are dynamic.
Eg1:-
x={}
print(x)
print(type(x))
Output:
{}
<class 'dict'>
Eg2:-
y=dict
print(y)
print(type(y))
Output:
<class 'dict'>
<class 'type'>
Eg3:-
z={"jaja":80,"python":99,"handdop":86}
print(z)
Output:
{'jaja': 80, 'python': 99, 'handdop': 86}
Eg4:-
x={"jaja":80,"python":99,"handdop":86}
print(x)
print(x["python"])
print(x.get("handdop"))
x["aws"]=89
print(x)
x["devops"]=86
print(x)
y={101:True,123.123:"python","lokesh":3+4j}
print(y)
Output:
{'jaja': 80, 'python': 99, 'handdop': 86}
99
86
{'jaja': 80, 'python': 99, 'handdop': 86, 'aws': 89}
{'jaja': 80, 'python': 99, 'handdop': 86, 'aws': 89, 'devops': 86}
{101: True, 123.123: 'python', 'lokesh': (3+4j)}
Eg4:-
x={"jaja":80,"python":99,"handdop":86}
print(x)
print(x["python"])
print(x.get("handdop"))
x["aws"]=89
print(x)
x["devops"]=86
print(x)
y={101:True,123.123:"python","lokesh":3+4j}
print(y)
Output:
{'jaja': 80, 'python': 99, 'handdop': 86}
99
86
{'jaja': 80, 'python': 99, 'handdop': 86, 'aws': 89}
{'jaja': 80, 'python': 99, 'handdop': 86, 'aws': 89, 'devops': 86}
{101: True, 123.123: 'python', 'lokesh': (3+4j)}
Post a Comment
0 Comments