1. In Python - which of the following options has been declared as a list?
#Option 1
list1={1,2,3,4,5}
#Option 2
list2=[1,2,3,4,5]
#Option 3
list3=<1,2,3,4,5] VIDEO
None of the lists shown are lists!
Option 2
Option 3
Option 1
2. What is wrong with the creation/declaration of this list?
3. You want the output to be 'zara' and '200'. What do you need to change?
list1, list2 = [123, 'xyz', 'zara', 'abc'], [456, 700, 200]
print "Max value element : ", max(list1)
print "Max value element : ", max(list2)
Change line 3 to print "Min value element : ", min(list2)
Change line 3 to: print "Min value element : ", max(list2)
This cannot be done
Change line 2 to: print "Max value element : ", min(list2)
4. You want the output to be '123','xyz','abc' - what do you need to change?
5. What do you need to put on line 2 in order to sort the list?
aList = [6,2,3,7,1,4,5];
#What needs to go here to get the output of 1,2,3,4,5,6,7?
print "List : ", aList
sort(aList):
aList.sort();
aList.quicksort();
sort().lista
6. ave you heard anyone say: "I look up at the night sky and saw an array of stars". The word array suggests …..
7. The following code employs the use of a list. What would the output be if you entered "Mathematics" at the input prompt?
8. In a language like Python you don't 'declare' an array like you would in VB.Net but lists function in a similar way.
9. What is the output for the following?
10. What is different about the list 'matrix'?
11. In this 2d array (matrix) why is the output 6?
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(matrix[1][2])
The output is 2, not 6
Because 1 x 2 + 3 = 6. There are three lists within the list and the index numbers are 1 and 2
Because it is searching for the second list (0…1) and the third element in that list (0…1…2), which is 6
None of the above
12. Trial the following code. On what line are the usernames that are entered being added to the list 'usernames'?
13. In the following python task (which you can attempt if you have the time) the third player is not assigned a weapon. Why?
14. What one word do you need to add on line 3 for this whole mini program to work
15. What does this code do?