Unit 11 : Data Collection Flashcards
What does rstrip() does?
- Remove the white space at right side
What does find() does?
- Find the string inside a file
What allows duplicate data, ordered and changeable?
- List
mylist = [1,2,3]
- Arrary , the order [0]
What allows duplicate data, ordered and unchangeable?
- Tuple
mytuple = ( “Adam”,”bob”)
What doesn’t allow duplicate data, unordered, unchangeable and unindexed?
- Set
myset = { “Dan” , “Chris”}
What doesn’t allow duplicate data, ordered and changeable?
- Dictionary
mydict = {
“name” : “Adam” ,
“password” : “123” ,
“role” : “chef”
}
print(mydict[“password”])
What is list used for?
- Group similar items
- Ordered, changeable and allow duplicate values
What is list defined by?
- Square brackets [ ]
How can we create list ? ( 4 )
- new_list = []
- new_list = [ 3, 4, 5, 6 ]
- new_list = list(range(10))
- new_list = list(range(2,7))
How can we add element? ( 2 )
- new_list[3] = 145
- new_list.append(3)
Can list insert different types of data ? ( newlist = [ 1 , “Adam” ] )
- Yes
How to add another list ? ( 2 )
- new_list[2] = new_list2
- newlist,append(new_list[2])
How to print out the list?
- print(new_list)
How to print the exact list?
- print(new_list[2])
How to print the list range?
- print(new_list[0:3])
- This will take the value in list between 0 , 1 , 2