click below
click below
Normal Size Small Size show me how
IT0011-FA4
Integrated Programming
| Question | Answer |
|---|---|
| Tuples are immutable. | True |
| Given the code below: aTuple = “Yellow”, 20, “Red” a, b, c = aTuple print (c) What will be the output? | Red |
| Given the code below: aTuple = (10, 20, 30, 40, 50) print(aTuple[:4]) What will be the output? | (10, 20, 30, 40) |
| To change the value of a specific item, refer to the index number. | True |
| You can loop through a dictionary by using a for loop. | True |
| The copy() method returns a copy of the dictionary. | True |
| Tuple is a collection which is ordered and unchangeable. | True |
| Given the code below: aTuple = (10, 20, 30, 40, 50) print(aTuple[2:4]) What will be the output? | (30, 40) |
| What method used to add more than one item to a set? | update() |
| Make a copy of a dictionary with the dict() method. | True |
| Given the code below: a = {5,4} b={1,2,4,5} a<b What will be the output? | True |
| Tuple is a collection which is ordered and changeable. | False |
| Tuples are mutable. | False |
| List is a collection which is ordered and unchangeable Square brackets can be used to access elements of the string. | False |
| What method removes the specified index? | pop() |
| You cannot convert the tuple into a list. | False |
| What method used to return a copy of the dictionary? | copy() |
| You can change the value of a specific item by referring to its key name. | True |
| Adding an item to the dictionary is done by using a new index key and assigning a value to it. | True |
| When using the pop() method in set, the item that gets removed is unknown. | True |
| Which of the following will empty a given list called item. | item.clear() |
| Suppose t = (1, 2, 4, 3), which of the following is incorrect? | t[3] = 45 |
| Given the code below: aTuple = (100, 200, 300, 400) print(aTuple[3]) What will be the output? | 400 |
| List is a collection which is unordered and changeable | False |
| The get() method returns the value of the specified key. | True |
| To add one item to a set use the add() method. | True |
| A dictionary is a collection which is unordered, changeable and indexed. | True |
| Given the code below: aTuple = (10, 20, 30, 40, 50) print(aTuple[3:]) What will be the output? | (40, 50) |
| List is a collection which is ordered and changeable. | True |
| You cannot access items in a set by referring to an index. | True |
| Which of the following collection is unordered, changeable and indexed. | dictionary |
| To add more than one item to a set use the add() method. | False |
| The clear() keyword empties the dictionary. | True |
| Given the code below: x = list (('abc',23, (78,16),3.14,[1,2,3,4])) print(x[0][1:]) What will be the output? | bc |
| Given the code below: x = list (('abc',23, (78,16),3.14,[1,2,3,4])) print(x[:3]) | [‘abc’,23,(78,16)] |
| Dictionary is a collection which is unordered and unindexed. | False |
| You can loop through a dictionary by using while loop. | False |
| Given the code below: d = {“john”:40, “peter”:45} “john” in d What will be the output? | True |
| When using the pop() method in set, the item that gets removed is known. | False |
| Given the code below: >>>t = (1, 2) >>>2 * t What will be the output? | (1, 2, 1, 2) |
| Which of the following is a Python tuple? | (1, 2, 3) |
| When specifying a range, the return value will be a new list with the specified items. | True |
| In Python tuples are written with square brackets | True |
| What method is used to return a new set containing all items from both sets? | union() |
| What method used to remove an item in a set? | pop() |
| The pop() method can be used to remove an item in a set. | True |
| A set is a collection which is unordered and unindexed. | True |
| A list is a collection which is unordered and unindexed. | False |
| The union() method is used to return a new set containing all items from both sets. | True |
| In Python sets are written with curly brackets. | True |
| Given the code below: aTuple = (100, 200, 300, 400, 500) print(aTuple[-3:-1]) What will be the output? | (300, 400) |
| Given the code below: aTuple = (10, 20, 30, 40, 50) print(aTuple[2:5]) What will be the output? | (30, 40, 50) |
| Given the code below: n = [4,2,8,5,7] n.append(3) print(n) What will be the output? | [4,2,8,5,7,3] |
| To add more than one item to a set use the update() method. | True |
| A set is a collection which is unordered, changeable and indexed. | False |