Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

3.i_ \\'ntc a program to a'C21c. concatcna1c Int.

I print a \tnnp :and '"<' ing uh


Mnng from agtvcn \tring

pnnc("thc value o( \ u·" v)

stnng_add = w

print("Wet conea1.cn11bo£ \ v I.be Ntltti ''",...,...-)

tc:t1•"The val or pi it·-t str(pl)

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:

-iISTllT: C:/U1mld•ll/0!1tt.p/)'th(c roqrw/ml."l_ Ol>mt1w.v1-


ll>t fll't of IIs: Ve>btt
Ill• Tile• ol ' u: Schlu.w711
alm co:em.·.;: 'w v m ml"I Is: vwmi lll:li'll
llO?t: l'U!ltlu l!i;tt .... opel!Wi; ..,, QQl;ftIR!f to nn.z:q btfO.t! Ul.DG -u ltflJ
o:Ur v1Jt Tll<:t vill bf 00."11dmd u m clu1
:1'11' It< ,Tll<:t o!Pl II l.l!

!.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 = ["SUET", "GNIT", "AYN"]


print(colleges)

# appending new college in collges list

colleges.append(" MVSR")

#checking if its added or not


print(colleges)

#adding a new college at a positon.

colleges.iasert( l,"BHARAT") print(coll eges)

#remove a name from colleges

colleges.remove("BHARAT")

print(colleges)

#remove a name with an index value

del colleges[ l]

# NOTE: index starts from 0 so 2nd value in list will be removed

print(colleges)

Output:
,,
,
========== RESTART : C :/ Users/dell/ Deskt op/pyt hon programs/ lists .py =====--
===:
SIIET I' IGNIT I ' IAVN I 1
[ I

[ 'SIIET ' , 'GNIT ' , 'AVN ' , 'MVSR ' ]


[ 'SIIET ' , 'BHARAT ' , ' GNIT ' , 'AVN ' , 'MVSR ' ]
[ 'SIIET ' , 'GNII ' ,'AVN ' , 'MVSR ' ]
[ 'SIIET ' , 'AVN ' , 'MVSR ' ]
I
6. Write a program to demonstrate working with tuples inpython

# creating tuples with college names..

colleoes = ("SUET","BHARAT"'"GNIT", "AVN")

print("the lists in colleges tuple is",colleges)

print("we can\'t add or remove new elements in a tuple")

print("length of the tuple colleges is:",len(coEleges))

# checking whether 'SII ET' is present in the tuple or not

if "SIIET" in colleges:

print("Yes, 'SUET' is in the colleges tuple")

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:

RESTART: C:/Users/dell/Deskt:op/python programs/dic ionaries .py =======


name I: Isiiet II Icode I : 'INDII, Iid I : Ix3 I }
{ I

{'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' )

You might also like