Professional Documents
Culture Documents
Practical - Colaboratory
Practical - Colaboratory
Question 1
list1=["Car",12,"Bike",5,"Aircraft",10,30,"Boat",53,"Railway"]
list1
print(len(list1))
10
list1.reverse()
print (list1)
for i in list1[0:3]:{
print(type(i))
<class 'str'>
<class 'int'>
<class 'str'>
list1.clear()
print (list1)
[]
Question 2
string="""#### KC COLLEGE PROVIDES VARIOUS COURES LIKE Msc In $STATS, Msc IN $CHEMISTRY,Msc IN $BIOTECHNOLOGY,BACHELORS IN $COMPUTER SCIENCE WITH ALL NECESSARY EQUIPMENTS AND TECHNICAL LABS REQUIRED FOR PRACTICALS #######"""
string1=string.strip("#")
string1
' KC COLLEGE PROVIDES VARIOUS COURES LIKE Msc In $STATS, Msc IN $CHEMISTRY,Msc IN $BIOTECHNOLOGY,BACHELORS IN $COMPUTER SCIENCE WITH ALL NECESSARY EQUIPMENTS AND TECHNICAL LABS REQUIRED FOR PRACTICALS '
string2=string1.replace("$"," ")
string2
' KC COLLEGE PROVIDES VARIOUS COURES LIKE Msc In STATS, Msc IN CHEMISTRY,Msc IN BIOTECHNOLOGY,BACHELORS IN COMPUTER SCIENCE WITH ALL NECESSARY EQUIPMENTS AND TECHNICAL LABS REQUIRED FOR PRACTICALS '
string3=string2.lower()
string3
' kc college provides various coures like msc in stats, msc in chemistry,msc in biotechnology,bachelors in computer science with all necessary equipments and technical labs required for practicals '
wordcount=string3.count("msc")
wordcount
splittext=string3.split(",")
splittext
'msc in biotechnology',
'bachelors in computer science with all necessary equipments and technical labs required for practicals ']
stringpartition=string3.partition("msc")
stringpartition
'msc',
' in stats, msc in chemistry,msc in biotechnology,bachelors in computer science with all necessary equipments and technical labs required for practicals ')
Question 3
cardata={"Fiat":5000,"Ford":10000,"Tesla":8000,"Tata":7000,"Nisan":9000}
cardata
{'Fiat': 5000, 'Ford': 10000, 'Nisan': 9000, 'Tata': 7000, 'Tesla': 8000}
for key in cardata:
print([key])
['Fiat']
['Ford']
['Tesla']
['Tata']
['Nisan']
cardata.keys()
for val in cardata:
print(cardata[val])
5000
10000
8000
7000
9000
cardata.values()
list1=(cardata.keys())
list1
list2=(cardata.values())
list2
cardata.update({"Ferrari":12000})
cardata
{'Ferrari': 12000,
'Fiat': 5000,
'Ford': 10000,
'Nisan': 9000,
'Tata': 7000,
'Tesla': 8000}
cardata.clear()
cardata
{}