The number of 6-digit even numbers that can be made from the number 214635 are:
.png)
Our wonderful journey is still continued.
Please have a watch on the before blog because this blog is extension to vefore blog . Have a look at that Previous .
Context
Lists
Operations
PYTHON LISTS
What is use of lists ?
It is used to make a collection of items. Like in the above pictures.
In this list , we can store in all data types like string, integer etc,.
Syntax :
A = [var1 , var2, var3.. ........]
where,
A = name of the list
var1,var2,vars are the elements in the list.
Eg :
list = ["apples", "banana", "cherry"]
See this video 👇👇👇👇
Lets move on to operations in lists
Indexing :
Same what we have learnt in strings.
Syntax :
List[0] # for accessing the first element in list
List[1] # second element
Slicing :
Even this also same as it string.
Eg :
list[0:2] # prints the elements in index 0,1
# as we all know second index omitted
And biggest advantages in list over the string . Lists can be updated at any time in programmme.
For adding and deleting we have a inbulit functions.
For adding elements : append function
For deleting a element : del function.
Adding a element in list
Code :
list.append("kiwi")
Deleting a element in list
Code :
del list[0] # deleting a element in index '0'
Checking the length of list :
Updated list
list = ["banana", "cherry" , "kiwi"]
Code :
len(list)
Repeating a list miltiple times.
Code
list*2 # repeats the list 2 times
Concatenation of two lists
List2 = ["carrots" , "beetroot"] # new list
List + list2
You can also print the maximum and minimum number in list .
Take a new list which will contain numbers
num = [1,4,6,7,5,9]
max(num)
min(num)
Hope this videos are helpful. comment me for further suggestions.
Comments
Post a Comment