diff --git a/session_01/exercises/multiple_choice_1.md b/session_01/exercises/multiple_choice_1.md index 6f1d6a71..e1b93de5 100644 --- a/session_01/exercises/multiple_choice_1.md +++ b/session_01/exercises/multiple_choice_1.md @@ -1,68 +1,79 @@ # KPMG:Code - Session 1 - Multiple Choice Questions -1. What is programming? +1. What is programming? + - Giving the computer instructions - A -- Choosing a television show +- Choosing a television show - Knitting a scarf -- Completing some math equations +- Completing some math equations 2. What is a text editor? + - A place to write an essay -- A place to write code - A +- A place to write code - A - A place to write a report -- A place to edit a novel +- A place to edit a novel + +3. When naming a Python file, what is the file extension used? -3. When naming a Python file, what is the file extension used? - .doc - .xlsx - .py - A -- .csv +- .csv + +4. What does print() do? -4. What does print() do? - prints out a document to a printer -- prints the code output to the screen - A -- 3D prints a Python -- posts to social media +- prints the content to the screen - A +- 3D prints a Python +- posts to social media + +5. What are the rules for variables? -5. What are the rules for variables? - Lowercase - Underscore instead of spaces - No punctuation -- All of the above - A +- All of the above - A 6. Which of the below is a string? + - "hello world" - A - 6 - True - 7.9 -7. Which of the below is a float? +7. Which of the below is a float? + - "hello world" - 6 - True -- 7.9 - A +- 7.9 - A + +8. Which character lets you put in a new line? -8. Which character lets you put in a new line? - \n - A - /n - \t - \l -9. What will be the output of the below: +9. What will be the output of the below: + first_name = "Steve" last_name = "Shirley" full_name = first_name + " " + last_name -print("Good morning, " + full_name) +print("Good morning, " + full_name) -- Good morning Steve -- Good evening Steve -- Good morning Steve Shirley - A -- Good morning Shirley +- Good morning Steve +- Good evening Steve +- Good morning Steve Shirley - A +- Good morning Shirley + +10. What will be the output of the below: -10. What will be the output of the below: correct_sum = 4 + 5 * 2 -print(correct_sum) +print(correct_sum) + - 18 - 14 - A -- 13 -- 0 \ No newline at end of file +- 13 +- 0 diff --git a/session_02/exercises/multiple_choice_2.md b/session_02/exercises/multiple_choice_2.md index 79b3e044..b0bf387c 100644 --- a/session_02/exercises/multiple_choice_2.md +++ b/session_02/exercises/multiple_choice_2.md @@ -1,27 +1,31 @@ # KPMG:Code - Session 2 - Multiple Choice Questions 1. What is concatenation? + - adding cats together -- adding strings together - A +- adding strings together - A - a celebration - a function -2. To create a comment in code, what do you put before it? +2. To create a comment in code, what do you put before it? + - ! -- # - A +- # - A - ? - % 3. What will be the output of the below? + a = int(2.6) print (a) - 2.6 - two point six - True -- 2 - A +- 2 - A 4. How can you fix the below error? + age = 21 # ERROR: TypeError: can only concatenate str (not "int") to str @@ -33,6 +37,7 @@ print("You are: " + age + " years old") - cast the age variable to a float 5. What is the output of below? + name = "Ada Lovelace!" name_length = len(name) print(name_length) @@ -40,9 +45,10 @@ print(name_length) - 10 - 11 - 12 -- 13 - A +- 13 - A 6. What is the output of below? + animal = "Giraffe" print(animal[0]) @@ -51,28 +57,32 @@ print(animal[0]) - e - E -7. Which prints out the last element of a string? -- print("python"[-1]) - A +7. Which prints out the last element of a string? + +- print("python"[-1]) - A - print("python"[0]) - print("python"[-4]) - print("python"[1]) -8. What function takes an input from a user? +8. What function takes an input from a user? + - enter() - print() -- input() +- input() - A - add() -9. What will be the output of the below: +9. What will be the output of the below: + colour = "yellow" -print(colour.upper()) +print(colour.upper()) -- Yellow +- Yellow - yellow -- YELLOW - A -- YeLLow +- YELLOW - A +- YeLLow + +10. What will be the output of the below: -10. What will be the output of the below: fullname = "Alan" + "Turing" length = len(fullname) middle_letter = fullname[int(length / 2)].lower() @@ -81,5 +91,5 @@ print("The middle letter of your name is " + middle_letter) - A - u - A -- t -- G \ No newline at end of file +- t +- G diff --git a/session_03/exercises/multiple_choice_3.md b/session_03/exercises/multiple_choice_3.md index 64bc8846..8285f19b 100644 --- a/session_03/exercises/multiple_choice_3.md +++ b/session_03/exercises/multiple_choice_3.md @@ -1,12 +1,14 @@ # KPMG:Code - Session 3 - Multiple Choice Questions 1. What is a conditional? + - an expression that allows a user to enter an input - an expression that allows a computer to make a decision - A - an expression that allows a computer to print an output - an expression that makes a string upper case 2. What will be the output of the below: + sum = 5 + 6 if sum == 10: @@ -18,6 +20,7 @@ if sum == 10: - 11 3. What will be the output of the below: + name = "Jackie" if name == "Anita": @@ -46,6 +49,7 @@ print("Thanks") - less than or equal to 6. What is the output of below? + age = 15 if age >= 21: print("You can vote") @@ -56,20 +60,22 @@ else: - You cannot vote - A 7. What is the output of below? + traffic_light = "red" if traffic_light == "green": print("You can go!") elif traffic_light == "amber": - print("Get ready to stop..") + print("Get ready to stop...") else: print("STOP!") - Get ready to stop.. -- STOP! -- You can go! - A +- STOP! - A +- You can go! 8. What will be the output of the below: + age = 0 if age <= 13: @@ -87,14 +93,16 @@ else: - You are 19 or over 9. What will be the output of the below: + age = 14 if age > 12 and age < 20: print("You are a teenager") -- You are a teenager +- You are a teenager - A - You are not a teenager 10. What will be the output of the below: + age = 12 if age < 13 or age > 19: print("You are not a teenager") diff --git a/session_04/exercises/multiple_choice_4.md b/session_04/exercises/multiple_choice_4.md index 408da1f0..99dff0e9 100644 --- a/session_04/exercises/multiple_choice_4.md +++ b/session_04/exercises/multiple_choice_4.md @@ -1,18 +1,21 @@ # KPMG:Code - Session 4 - Multiple Choice Questions 1. What is a list? + - a way to allow user input - a statement that allows a computer to make a decision - a way to print an output -- a collection of data - A +- a collection of data - A 2. What brackets does a list use? + - {} - () -- [] - A +- [] - A - <> 3. What will be the output of the below: + flowers = ["tulip", "rose", "snowdrop", "lily"] print(flowers[-1]) @@ -22,6 +25,7 @@ print(flowers[-1]) - lily - A 4. What will be the output of the below: + flowers = ["tulip", "rose", "snowdrop", "lily"] flowers[2] = "sunflower" @@ -29,10 +33,11 @@ print(flowers) - ["sunflower", "rose", "snowdrop", "lily"] - ["tulip", "sunflower", "snowdrop", "lily"] -- ["tulip", "rose", "sunflower", "lily"] - A +- ["tulip", "rose", "sunflower", "lily"] - A - ["tulip", "rose", "snowdrop", "sunflower"] 5. What will be the output of the below: + birds = ["albatross", "buzzard", "chicken"] if "chicken" in birds: @@ -44,6 +49,7 @@ else: - A chicken isn't here 6. To print out the numbers 0-100, fill in the blank: + for num in range(?): print(num) @@ -52,39 +58,44 @@ for num in range(?): - 101 - A - 0 -7. A for loop is used for iterating over a sequence. +7. A for loop is used for iterating over a sequence? -- True - A -- False +- True - A +- False + +8. What will be the output of the below: -8. What will be the output of the below: total = 0 -for num in range(1,4): - total += num +for num in range(1, 4): + total = total + num print(total) -- 0 +- 0 - 2 -- 4 -- 6 - A +- 4 +- 6 - A + +9. What will be the output of the below: -9. What will be the output of the below: names = ["Saf", "Anita", "Jake", "Jackie"] captains = [] + for name in names: captains.append("Captain. " + name) + print(captains) - ["Dr. Saf", "Dr. Anita", "Dr. Jake", "Dr. Jackie"] -- ["Captain. Saf", "Captain. Anita", "Captain. Jake", "Captain. Jackie"] +- ["Captain. Saf", "Captain. Anita", "Captain. Jake", "Captain. Jackie"] - A - ["Capn. Saf", "Capn. Anita", "Capn. Jake", "Capn. Jackie"] - ["Saf", "Anita", "Jake", "Jackie"] -10. What will be the output of the below: -for x in range(1,10,2): -print(x) +10. What will be the output of the below: + +for x in range(1, 10, 2): + print(x) - The even numbers from 1 to 10 -- The odd numbers from 1 to 10 - A \ No newline at end of file +- The odd numbers from 1 to 10 - A diff --git a/session_05/exercises/multiple_choice_5.md b/session_05/exercises/multiple_choice_5.md index 0bd08a82..5fc3d510 100644 --- a/session_05/exercises/multiple_choice_5.md +++ b/session_05/exercises/multiple_choice_5.md @@ -1,39 +1,45 @@ # KPMG:Code - Session 5 - Multiple Choice Questions 1. What is a module? -- a library of code we can reuse in our code - A + +- a library of code we can reuse in our code - A - a statement that allows a computer to make a decision - a way to print an output - a collection of data 2. What key word brings the module in so our code can use it? + - bring - input -- import - A +- import - A - contain -3. What does the random.randint() function do? -- picks a random number from 0 to 1 -- picks a random number from a range you specify - A +3. What does the random.randint() function do? + +- picks a random number from 0 to 1 +- picks a random number from a range you specify - A - picks a random item from a list - picks a random function -4. What does the random.choice() function do? -- picks a random number from 0 to 1 +4. What does the random.choice() function do? +- picks a random number from 0 to 1 - picks a random number from a range you specify -- picks a random item from a list - A +- picks a random item from a list - A - picks a random function 5. What will be the output of the below: + import math + print(math.ceil(4.2)) - 4 - 5 - A - 4.2 -- 5.2 +- 5.2 6. What number will stop this while loop: + guess = None while guess != 4: guess = int(input("What's your number? ")) @@ -44,35 +50,38 @@ while guess != 4: - 7 7. How many times will "Hello" be printed? + times_in_loop = 0 while times_in_loop >= 0: print("Hello") times_in_loop += 1 if times_in_loop > 5: - break + break - 0 - 4 - 5 - 6 - A -8. The below loop will not run forever: +8. The below loop will NOT run forever? + times_in_loop = 0 while times_in_loop >= 0: print("Hello") times_in_loop += 1 -- True -- False - A +- True +- False - A + +9. To print 5 random numbers, fill in the blank: -9. To print 5 random numbers, fill in the blanks: import random number = 0 while number <= ?: - print(random.?(1,10)) + print(random.?(1, 10)) number += 1 - 3, random @@ -80,9 +89,10 @@ while number <= ?: - 5, choice - 4, random -10. What will be the output of the below: -sum=0 -i=0 +10. What will be the output of the below: + +sum = 0 +i = 0 while i < 10: i += 1 @@ -93,4 +103,4 @@ print(sum) - 10 - 45 - 55 - A -- 100 \ No newline at end of file +- 100 diff --git a/session_06/exercises/multiple_choice_6.md b/session_06/exercises/multiple_choice_6.md index d5d0262c..b0dd8864 100644 --- a/session_06/exercises/multiple_choice_6.md +++ b/session_06/exercises/multiple_choice_6.md @@ -4,21 +4,21 @@ - a way to allow user input - a statement that allows a computer to make a decision - a way to print an output -- a collection of data - A +- a collection of data - A 2. What brackets does a dictionary use? - {} - A - () -- [] +- [] - <> 3. A dictionary is an unordered collection of data. -- True - A -- False +- True - A +- False 4. A tuple can be modified -- True -- False - A +- True +- False - A 5. What will be the output of the below: shirt = { @@ -30,10 +30,10 @@ print(shirt["size"]) - size - colour -- Large +- Large - A - Red -6. What would be the ouput of the below: +6. What would be the output of the below: contacts = [ {"fname": "Ada", "lname": "Lovelace"}, {"fname": "Alan", "lname": "Turing", "phone": "555-1234"}, @@ -45,8 +45,8 @@ for person in contacts: print(person["fname"]) - Ada -- Alan -- Steve - A +- Alan - A +- Steve - 555-1234 7. What will stop this while loop: @@ -65,17 +65,18 @@ while fname != "": - nothing, it will run forever - entering a first name -- not entering a first name +- not entering a first name - A - not entering a first name and last name 8. Items in a dictionary are called _____ pairs. -- key, value - A +- key, value - A - value, key - key, arguments - value, arguments -9. What will be the output of the below: +9. What will be the result of the below: + shirt = { "size": "Large", "colour": "Red" @@ -84,19 +85,20 @@ shirt = { shirt["colour"] = "Green" - adds a new key/value -- changes an existing value - A +- changes an existing value - A - deletes the key/value pair -- prints out the dictionary +- prints out the dictionary + +10. What will be the result of the below: -10. What will be the output of the below: shirt = { "size": "Large", "colour": "Red" } -del(shirt["size"]) +del(shirt["size"]) - adds a new key/value - changes an existing value - deletes the key/value pair - A -- prints out the dictionary \ No newline at end of file +- prints out the dictionary diff --git a/session_07/exercises/multiple_choice_7.md b/session_07/exercises/multiple_choice_7.md index 70cb6f83..3a9b2e0c 100644 --- a/session_07/exercises/multiple_choice_7.md +++ b/session_07/exercises/multiple_choice_7.md @@ -1,33 +1,38 @@ # KPMG:Code - Session 7 - Multiple Choice Questions 1. What is a function in Python? + - a way to allow user input - a statement that allows a computer to make a decision - re-usable, self-contained blocks of code that do a single task - A - a collection of data 2. What key word defines a function? + - def - A - input - print - parameter 3. How would I call the following function: + def hello_world(): print("Hello World!") - hello_world -- hello world () -- hello_world() - A +- hello world () +- hello_world() - A - hello world 4. What does the principle of 'DRY' stand for? -- do repeat yourself + +- do repeat yourself - don't repeat yourself - A - do return yourself - don't reload yourself 5. What is name classed as here: + def hello(name): print("Hello, " + name + "!") @@ -36,41 +41,44 @@ def hello(name): - parameter - A - class -6. What would be the ouput of the below: +6. What would be the output of the below: + def hello(name): print("Good Morning, " + name) hello("Grace") - Grace -- Good Morning Grace Hopper -- Good Morning Grace - A -- good morning Grace +- Good Morning, Grace Hopper +- Good Morning, Grace - A +- good morning, Grace + +7. What would be the output of the below: -7. What would be the ouput of the below: def volume(x, y, z): print("The volume is " + str(x * y * z)) volume(12, 4, 6) -- 228 +- 228 - 288 - A -- 114 +- 114 - 144 -8. What is returning, in relation to functions? +8. What is "return", in relation to functions? -- return is a keyword - A +- return is a keyword - A - return is a function - return is a input -- return is a parameter +- return is a parameter -9. Which of the below will stop the execution a function? +9. Which of the below will stop the execution a function? - print -- return - A +- return - A + +10. What will be the output of the below: -10. What will be the output of the below: def calc_factorial(x): if x == 1: return 1 @@ -84,4 +92,4 @@ print(calc_factorial(num)) - 4 - None - 24 - A -- 6 \ No newline at end of file +- 6 diff --git a/session_08/exercises/multiple_choice_8.md b/session_08/exercises/multiple_choice_8.md index 2da6cf29..0e7fff3e 100644 --- a/session_08/exercises/multiple_choice_8.md +++ b/session_08/exercises/multiple_choice_8.md @@ -1,41 +1,48 @@ # KPMG:Code - Session 8 - Multiple Choice Questions 1. To open the below file, fill in the missing word: + f = ?("my_file.txt", "r") + - input - read - open - A - close 2. To read the below file, fill in the missing word: + f = open("my_file.txt", "r") print(f.?()) + - input - read - A - open - close -3. What does the "a" mode stand for? +3. What does the "a" mode stand for? + - read -- append - A +- append - A - write - create 4. "w" mode, overwrites the contents of your file. -- True - A + +- True - A - False 5. "a" mode, overwrites the contents of your file. -- True -- False - A +- True +- False - A 6. "r" mode will fail if the file it's passed to doesn't exist. -- True - A -- False +- True - A +- False 7. To close the below file, fill in the missing word: + f = open("example.txt", "w") f.write("Hello World") f.?() @@ -43,15 +50,15 @@ f.?() - input - read - open -- close - A +- close - A 8. To create a new file, file in the missing mode: f = open("example.txt", "?") -- x - A +- x - A - c - r -- s +- s 9. What will be the output of the below: @@ -61,12 +68,13 @@ for x in open("example.txt"): print(total) -- all the text from the file will be output -- all the lines will be print out -- the amount of lines in the file will be printed out - A -- a new file will be created +- all the text from the file will be output +- all the lines will be print out +- the number of lines in the file will be printed out - A +- a new file will be created + +10. What will be the output of the below: -10. What will be the output of the below: f = open("odd.txt", "w") for x in open("numbers.txt"): @@ -78,5 +86,5 @@ f.close() - all the even numbers will be written to numbers.txt - all the odd numbers will be written to numbers.txt -- all the even numbers will be written to even.txt -- all the odd numbers will be written to odd.txt - A \ No newline at end of file +- all the even numbers will be written to even.txt +- all the odd numbers will be written to odd.txt - A