Python
Basics Of LIST
#it is like array#we can store multiple data type i list like int ,float,char
student=["rohan","kumar","nitin"] #pirticular index value
print(student[0]);
print(student[2]); #pirticular index value print
#"""Output
#rohan
#nitin
#"""
############################################################################
#if we want to add mor entry in give list WE us "append" function
student.append("amit");
print(student);
#"""output
#['rohan', 'kumar', 'nitin', 'amit']"""
#####################################################################
#update pirtucular index value
student[1]="vivek"
print(student);
#"""""output
#['rohan', 'vivek', 'nitin', 'amit']
#"""""
######################################################################
#if we have many student with same name in list
student.append("rohan");
print(student)
#"""""output
#['rohan', 'vivek', 'nitin', 'amit', 'rohan']"""
print(student.count("rohan")) #print how many times rohan comes in list
#"""output = 2"""
#########################################################################
student.remove("rohan") ##it works left to right so that when we remove rohan it remove left one first
print(student)
#"""output
#['vivek', 'nitin', 'amit', 'rohan']
#""""
########################################################################
student.sort() ## sort the list
print(student)
#"""""output
#['amit', 'nitin', 'rohan', 'vivek']"""""
############# reverse the give list#####################################
student.reverse()
print(student)
#"""output
#['vivek', 'rohan', 'nitin', 'amit']
#""""
############## concatnet two list#################################
student2=["kavita","pinki","raji"]
students=student+student2
print(students)
#"""""output
#['vivek', 'rohan', 'nitin', 'amit', 'kavita', 'pinki', 'raji']""""
###################################################################
mark=[99,45,65,35]
print( "thiss is max number from above lisy:" )
print(max(mark))
#output= 99
print(min(mark))
#output= 35
Comments
Post a Comment