Thursday, December 10, 2020

python day 8 list

 '''

day 8 list ,tuples,



#example1:

    

fruits =[]

print(fruits)

print(type(fruits))



fruits =[1]

print(fruits)

print(type(fruits))




fruits =[1,2,3,3,3,3,3,3,3,3,3,3,3,3]

print(fruits)

print(type(fruits))



fruits =[1,2,3,4,5]

print(fruits[0])

print(fruits[1])

print(fruits[2])

print(fruits[3])

print(fruits[4])

print(type(fruits))



fruits =[1,2,3,4,5]

for i in range(5):

    print(fruits[i])


print(type(fruits))


fruits =[1,2,3,4,5]

print(id(fruits[0]))

print(id(fruits[1]))

print(id(fruits[2]))

print(id(fruits[3]))

print(id(fruits[4]))

#print(id(fruits[0]))



fruits =[1,2,3,4,5]

print(fruits[-1])

print(fruits[-2])

print(fruits[-3])

print(fruits[-4])

print(fruits[-5])


fruits=["mango","apple","banana","grapes","orange"]

print(fruits[0])

print(fruits[1])

print(fruits[2])

print(fruits[3])

print(fruits[4])

print(type(fruits))

print(fruits[-1])

print(fruits[-2])

print(fruits[-3])

print(fruits[-4])

print(fruits[-5])


flowers=["rose","lotus","lilli","jasmine","chamanthi"]

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])

print(flowers[4])


fruits=["rose","lotus","lilli","jasmine","chamanthi"]

print(fruits[0])

print(fruits[1])

print(fruits[2])

print(fruits[3])

print(fruits[4])


flowers=["rose","lotus","lilli","jasmine","chamanthi"]


flowers.append("mandara")


flowers.append("chitti gulabi")

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])

print(flowers[4])

print(flowers[5])

print(flowers[6])



flowers=["rose","lotus","lilli","jasmine","chamanthi"]

flowers.insert(0,"gilledu")

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])

print(flowers[4])

print(flowers[5])



flowers=["rose","lotus","lilli","jasmine","chamanthi"]

flowers.insert(3,"gilledu")

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])

print(flowers[4])

print(flowers[5])



flowers=["rose","lotus","lilli","jasmine","chamanthi"]

flowers.remove("chamanthi")

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])



flowers=["rose","lotus","lilli","jasmine","chamanthi"]

flowers.pop(2)

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])



flowers=["rose","lotus","lilli","jasmine","chamanthi"]

flowers.sort()

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])




flowers=["rose","lotus","lilli","jasmine","chamanthi"]

flowers.reverse()

print(flowers[0])

print(flowers[1])

print(flowers[2])

print(flowers[3])

print(flowers[4])

'''

No comments:

Post a Comment

python class topic video