|
| 1 | +# KPMG:Code - Session 4 - Multiple Choice Questions |
| 2 | + |
| 3 | +1. What is a list? |
| 4 | +- a way to allow user input |
| 5 | +- a statement that allows a computer to make a decision |
| 6 | +- a way to print an output |
| 7 | +- a collection of data - A |
| 8 | + |
| 9 | +2. What brackets does a list use? |
| 10 | +- {} |
| 11 | +- () |
| 12 | +- [] - A |
| 13 | +- <> |
| 14 | + |
| 15 | +3. What will be the output of the below: |
| 16 | +flowers = ["tulip", "rose", "snowdrop", "lily"] |
| 17 | +print(flowers[-1]) |
| 18 | + |
| 19 | +- tulip |
| 20 | +- rose |
| 21 | +- snowdrop |
| 22 | +- lily - A |
| 23 | + |
| 24 | +4. What will be the output of the below: |
| 25 | +flowers = ["tulip", "rose", "snowdrop", "lily"] |
| 26 | +flowers[2] = "sunflower" |
| 27 | + |
| 28 | +print(flowers) |
| 29 | + |
| 30 | +- ["sunflower", "rose", "snowdrop", "lily"] |
| 31 | +- ["tulip", "sunflower", "snowdrop", "lily"] |
| 32 | +- ["tulip", "rose", "sunflower", "lily"] - A |
| 33 | +- ["tulip", "rose", "snowdrop", "sunflower"] |
| 34 | + |
| 35 | +5. What will be the output of the below: |
| 36 | +birds = ["albatross", "buzzard", "chicken"] |
| 37 | + |
| 38 | +if "chicken" in birds: |
| 39 | + print("A chicken is here") |
| 40 | +else: |
| 41 | + print("A chicken isn't here") |
| 42 | + |
| 43 | +- A chicken is here - A |
| 44 | +- A chicken isn't here |
| 45 | + |
| 46 | +6. To print out the numbers 0-100, fill in the blank: |
| 47 | +for num in range(?): |
| 48 | + print(num) |
| 49 | + |
| 50 | +- 99 |
| 51 | +- 100 |
| 52 | +- 101 - A |
| 53 | +- 0 |
| 54 | + |
| 55 | +7. A for loop is used for iterating over a sequence. |
| 56 | + |
| 57 | +- True - A |
| 58 | +- False |
| 59 | + |
| 60 | +8. What will be the output of the below: |
| 61 | +total = 0 |
| 62 | + |
| 63 | +for num in range(1,4): |
| 64 | + total += num |
| 65 | + |
| 66 | +print(total) |
| 67 | + |
| 68 | +- 0 |
| 69 | +- 2 |
| 70 | +- 4 |
| 71 | +- 6 - A |
| 72 | + |
| 73 | +9. What will be the output of the below: |
| 74 | +names = ["Saf", "Anita", "Jake", "Jackie"] |
| 75 | +captains = [] |
| 76 | +for name in names: |
| 77 | + captains.append("Captain. " + name) |
| 78 | +print(captains) |
| 79 | + |
| 80 | +- ["Dr. Saf", "Dr. Anita", "Dr. Jake", "Dr. Jackie"] |
| 81 | +- ["Captain. Saf", "Captain. Anita", "Captain. Jake", "Captain. Jackie"] |
| 82 | +- ["Capn. Saf", "Capn. Anita", "Capn. Jake", "Capn. Jackie"] |
| 83 | +- ["Saf", "Anita", "Jake", "Jackie"] |
| 84 | + |
| 85 | +10. What will be the output of the below: |
| 86 | +for x in range(1,10,2): |
| 87 | +print(x) |
| 88 | + |
| 89 | +- The even numbers from 1 to 10 |
| 90 | +- The odd numbers from 1 to 10 - A |
0 commit comments