Programfordatastructure.py

#collections

#list

lst=[2,5,6,78,2,0,“bharathi”,9.8,True]

print(lst[3])

print(lst)

print(lst[2:7])

#tuple

tuple=(2,3,4,5,‘mamatha’,34.56)

print(tuple)

tuple1=tuple

datatype=type(tuple)

datatype=type(tuple1)

print(tuple1)

#dictionary

dict_demo={‘a’:“Bharathi”,‘b’:“vaishnave”,‘c’:“ankit”}

print(dict_demo)

#set

set_demo={2,3,4,5,‘hello’,‘how’,‘you’}

print(set_demo)

set_demo.add(67)

print(set_demo)

#immutable

name=“bharathi”

print(“str:”,name)

#bool

#immutable

night=True

print(“Bool:”,night)

#complex

#immutable

comp = 2+9j

print(“complex:”,comp)

dict_demo={
“rno”:98,
“name”:“Bharathi”,
“subject”:(“english”,“maths”,“science”),
“hobbies”:[“coding”,“reading”,“writing”],
“details”:{“address”:“mumbai”,“office”:“pune”}
}
print(dict_demo[“name”])
print(dict_demo[“subject”][1])
print(dict_demo[“details”])

out put for above program
[2, 5, 6, 78, 2, 0, ‘bharathi’, 9.8, True]
[6, 78, 2, 0, ‘bharathi’]
(2, 3, 4, 5, ‘mamatha’, 34.56)
(2, 3, 4, 5, ‘mamatha’, 34.56)
{‘a’: ‘Bharathi’, ‘b’: ‘vaishnave’, ‘c’: ‘ankit’}
{2, 3, 4, 5, ‘how’, ‘you’, ‘hello’}
{2, 3, 4, 5, ‘how’, 67, ‘you’, ‘hello’}
str: bharathi
Bool: True
complex: (2+9j)

output:—
Bharathi
maths
{‘address’: ‘mumbai’, ‘office’: ‘pune’}