Professional Documents
Culture Documents
4214afaf (4 Files Merged)
4214afaf (4 Files Merged)
stnng_add = w
rnl\l("'NOl'f! \.Anllblcll after'+' opcnltlt \I bcc:o1n"C"tJ CO 11lrlRJ bdorc u11nr them ll.\'. \tnng. \n
ocfltt>A·ivalue will bcconsldcrtd b rt• da\\ l)ll("l
priat(Ct.tt)
()utpul:
!.Wnt.i:. .J python .cnpt 11> prini the cum:n1date ln following formal "Sun
M•y29 02-26:23 IST 2017"
Wri te a python program to create, append and remove lists in pyth on.
Source code:
# creating List with college names..
colleges.append(" MVSR")
colleges.remove("BHARAT")
print(colleges)
del colleges[ l]
print(colleges)
Output:
,,
,
========== RESTART : C :/ Users/dell/ Deskt op/pyt hon programs/ lists .py =====--
===:
SIIET I' IGNIT I ' IAVN I 1
[ I
if "SIIET" in colleges:
Output:
==== RESTART : C:/Users/dell/Desktop/python programs/tuples.py
====
the lists in colleges tuple is ('SIIET ', '8RARA 1
,
'GNIT ', 'AVN ') we can 't add or remove new elereents in
a tuple
length of the tuple colleges is:
4 Yes, 'SIIET' is in the
colleges tuple
7. Write a program to demonstrate working with dictionaries in python
Source code:
# creating a dicrionary
for SIIET college = {
"name": "si iet",
"code": "INDI",
"id": x3"
0
print(college)
#adding items tn dir.tinnary
college["location"] = "IBP"
print(college)
#changing values of a key
college["location"] = "sheriguda "
print(college)
# to remove items
use pop()
college.pop("code")
print (college)
#know the length using Len( )
print("length of college is:",Ien(college))
#to copy the same dictionary use copy()
mycollege= college.copy()
print (mycollege)
Output:
{'name ': 1 si1et 1 , 'code ': 'INDI', 'id ': 'x3', 'location ': 'IBP'}
{'nan:e': 1 s1iet', 'code' : 'INDI', 11d 1 : 'x3', 'location ': 'sheriguda '}
{'name ': 'siiet ', 'id': 'x3', 'location':
'sheriguda' } length of college is: 3
{'nan:e ': 'siiet ', 'id': 'x3', 'location': 'sheriguda' )