ECOR 1042 AB - Mock Final-2

docx

School

Carleton University *

*We aren’t endorsed by this school

Course

1042

Subject

Mechanical Engineering

Date

Apr 3, 2024

Type

docx

Pages

7

Uploaded by PrivateOryxPerson1069

Report
COURSE: ECOR 1042 AB FACILITATOR NAME: Becca Young and Braeden Kloke MOCK EXAM (FOR PRACTICE ONLY) It is most beneficial to you to write this mock final UNDER EXAM CONDITIONS . This means: Complete the exam in 2 hours. Work on your own and attempt every question. Keep your notes and textbook closed. Attempt the mock by hand. After the time limit, go back over your work with a different colour or on a separate piece of paper and try to do the questions you are unsure of. Record your ideas in the margins to remind yourself of what you were thinking when you take it up at PASS. The purpose of this mock exam is to give you practice answering questions in a timed setting and to help you to gauge which aspects of the course content you know well, and which are in need of further development and review. Use this mock exam as a learning tool in preparing for the actual exam. Please note: Complete the mock exam before attending the take-up session. During the session you can work with other students to review your work. Often, there is not enough time to review the entire exam in the PASS workshop. Decide which questions you most want to review – the Facilitator may ask students to vote on which questions they want to discuss in detail. Facilitators will not distribute an answer key for mock exams . The Facilitator’s role is to help students work together to compare and assess the answers they have. If you are not able to attend the PASS workshop, you can work alone or with others in the class. PASS worksheets are designed as a study aid only for use in PASS workshops. Worksheets may contain errors, intentional or otherwise. It is up to the student to verify the information contained within by attending the PASS workshop. Good Luck writing the Mock Exam!! Take-up Session #1: Monday, December 11th, 1:35-3:25pm (ML 402) With Becca Young Take-up Session #2: Tuesday, December 12th, 3:05-4:55pm (ML 402) With Braeden Kloke Office Hour: Thursday, December 14th, 7:00-7:25pm (ML 413) With Becca Young Contact Information: beccayoung@cmail.carleton.ca braedenkloke@cmail.carleton.ca
COURSE: ECOR 1042 AB FACILITATOR NAME: Becca Young and Braeden Kloke MOCK EXAM (FOR PRACTICE ONLY) Part A: Multiple Choice 1. What is bound to x after we run this code? my_list = [[15, 16, 22], [1, 2, 3], [55, 9, 0]] x = my_list[1][1] a) [15, 1] b) 1,2 c) 15 d) 2 2. Which of the following types cannot be used as a key within a python dictionary? a) tuple b) int c) string d) float e) list f) They can all be used. 3. What would be the most appropriate degree of polynomial to use for fitting a curve through five data points using interpolation? a) first degree b) second degree c) third degree d) fourth degree e) fifth degree 4. How many of these lines of code will work line_1 = “I like {name}, because it’s {space}”.format( name = “PASS”, space = “helpful”) line_2 = “I like {0}, because it’s {1}”.format(“PASS”, “helpful”) line_3 = “I like {}, because it’s {}”.format(“PASS”, “helpful”) line_4 = [“I like{}, because it’s{}”].format(“PASS”, “helpful”) a) 1 b) 2 c) 3 d) 4 e) None of the above 5. Students can connect to Brightspace from several devices at the same time. Suppose each connection is identified by the user’s student id and we’d like to know the number of students connected. Which collection should we use? a) List b) String c) Tuple d) Set e) Dictionary
COURSE: ECOR 1042 AB FACILITATOR NAME: Becca Young and Braeden Kloke MOCK EXAM (FOR PRACTICE ONLY) 6. What is the output of the following script assuming the user enters valid integers for both prompts? number_one = input("Input an integer: ") number_two = input("Input another integer: ") sum_val = number_one + number_two print(sum_val) a) The script will produce an error b) The sum of the two input integers c) None d) number_one attached to number_two e) None of these 7. What is the final value bound to z following the execution of the script below? t1 = (8, (4, 5)) t2 = (10, 2) a, b = t1 c, d = t2 z = d + a a) 14 b) 6 c) 18 d) 10 e) The code will produce an error 8. Suppose you have the following list of numbers to sort: [19, 1, 14, 2, 4, 90, 21]. Which of the following represents the sorted list after three iterations of insertion sort? a) [1, 2, 4, 14, 19, 90, 21] b) [1, 2, 4, 21, 19, 20, 90] c) [19, 1, 2, 14, 4, 21, 90] d) [1, 2, 4, 19, 14, 21, 90] e) [1, 2, 14, 19, 4, 90, 21] f) None of these
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
COURSE: ECOR 1042 AB FACILITATOR NAME: Becca Young and Braeden Kloke MOCK EXAM (FOR PRACTICE ONLY) 9. Which of the following statements will correctly strip the whitespace from both ends of the string? my_string = " Hello, world! " a) my_string.strip() b) my_string.replace(" ", "") c) my_string.split() d) All of the above 10. We have a dictionary with the names of students as keys and a list of percentage grades as the associated values. Suppose we want to add a 95 to Khai’s grades in the following dictionary: dictionary = { "leywin": [99, 99, 98] } How many of the following statements will work? dictionary["khai"] = dictionary["khai"].append(95) #1 dictionary["khai"] = dictionary.get("khai", []) + [95] #2 dictionary["khai"] += dictionary.get("khai", []) + [95] #3 dictionary.update({"khai" : dictionary.get("khai", []) + [95]}) #4 dictionary.update({"khai" : dictionary.get("khai", []).append(95)}) #5 dictionary.get("khai", []).append(95) #6 a)2 b) 3 c) 4 d) 5 e) 6 11. Which line of code will produce an error? import numpy # line 1 x = [1,2,3,4] # line 2 y = np.linspace(1, 5, 4) # line 3 coefficients = numpy.polyfit(x, y, 3) # line 4 a) line 1 b) line 2 c) line 3 d) line 4 d) There are no errors in the code 12. What is bound to x after this code is run?
COURSE: ECOR 1042 AB FACILITATOR NAME: Becca Young and Braeden Kloke MOCK EXAM (FOR PRACTICE ONLY) a_list = list(np.linspace(2.3, 55, 3)) x = len(a_list) a) 3 b) 55 c) 1 d) 54 Part B: Long Answer 1. Create a function alpha_count that prompts users to enter a single letter from the alphabet until the user enters a 0 – indicating they’d like to stop. The function should only accept single characters at a time or 0, any other input should result in some warning to the user. Internally, the function should keep count of the number of times each character was entered and, when the user quits, it should print all the letters entered by the user alongside the number of times it was input. Hint: Lists might not be the best approach.
COURSE: ECOR 1042 AB FACILITATOR NAME: Becca Young and Braeden Kloke MOCK EXAM (FOR PRACTICE ONLY) 2. How can we use Python to calculate the modulus of elasticity for a steel specimen based on its stress and strain values obtained by a team of engineering students? To achieve this, we can import the values from a CSV file and compute the line of best fit, which will enable us to find the slope of the stress vs strain curve. After finding the line of best fit, we can create a graph to represent the relationship between stress and strain. Write a function that imports the given table from a CSV file, plots the data points and line of best fit, and returns the modulus of elasticity. Stress (Mpa) Strain 5 2 7.1 3 9.4 3.9 11.5 4.7 14 7
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
COURSE: ECOR 1042 AB FACILITATOR NAME: Becca Young and Braeden Kloke MOCK EXAM (FOR PRACTICE ONLY) 3. Create a function get_best_average that accepts a dictionary which contains the grades of various students stored within lists: grades = { "shim": [65, 100, 73], "leywin": [20, 88, 75], "shay": [95, 99, 98] } The function should return the average of all the students. For the example above this would be 79.22 , you can have any number of decimals. You may also assume that each student has the same number of grades (3 each in the case above).