ECOR1041_B_Midterm_1

pdf

School

Carleton University *

*We aren’t endorsed by this school

Course

1041

Subject

Mathematics

Date

Feb 20, 2024

Type

pdf

Pages

7

Uploaded by MinisterFreedomSeaLion26

Report
Page 1 of 7 ECOR 1041 Mid-term Fall 2022 Section B - Exam Version 1 This is a closed-book exam. Non-programmable calculators are permitted. All other electronic devices (tablets, laptop computers, cell phones, smart watches, headphones, etc.) must be placed under your chair or left in your backpack or purse Sec1(/13) Sec2(/6) Sec3(/6) Penalties Total(/25) Student Name: Student Number: Section: This exam is 75 minutes long. There are three sections worth 25 marks in total on 7 pages. Attempt all questions. Use the back of the pages for “ rough work .” Do not ask questions unless you believe that you have found a typo. Be sure that you have clearly written your name and student number above. Not including your name or student number on this paper will result in a 5 marks penalty. Be sure you are writing this exam in your assigned room . Not writing in your assigned room will result in a 5 marks penalty. The multiple-choice questions in Section 1 must be answered using dark lead pencil . Answers to the questions in Section 2 and 3 must be written in black or blue indelible ink . If you write your Section 2 and 3 solutions in pencil instead of ink, your solutions will not be regraded if you believe there was a problem with the grading. All rights reserved : No part of this document may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission from the instructor.
Page 2 of 7 SECTION 1 - Multiple choice (…/13) This section contains 13 multiple-choice questions. Each question has one correct answer. Record your answers on the Scantron sheet . For each question, fill in (shade) the box (A, B, C, D or E) that corresponds to the correct answer. Answers recorded on the question paper will not be graded. Instructions Before you answer any questions, complete these fields on your Scantron sheet: Print your name in the LAST NAME and FIRST NAME fields and shade (fill in) the appropriate boxes below the fields. If your last name or first name has more characters than the number of columns in the field, print as many characters as will fit, starting with the first one. Print the course code, ECOR 1041B, in the COURSE NO and Section (S) fields and fill in the appropriate boxes below. Print the date, OCT 4 22, in the DATE OF EXAM field and fill in the appropriate boxes below. Starting at the leftmost column, print your 9-digit student number in the STUDENT NUMBER field and fill in the appropriate boxes below. Print the exam version number (stated on the cover page) in the EXAM VERSION NO field and fill in the appropriate box below. When answering the questions, Use a dark lead pencil (an HB #2 works well). Fill in (shade) the answers firmly and neatly. Completely erase any changed answers with a soft eraser. Do NOT staple, fold, crumple, or tear the sheet. Do NOT draw or write on the bar code black lines on the left-hand side of the sheet. Questions Q1 What would be the output of the following expression if someone types it in the Python shell: >>> 2(5//2)x4 a) 16 b) 16.0 c) 8 d) 8.0 e) Syntax error
Page 3 of 7 Q2 In Python brackets, [], braces, {}, and parentheses () are equivalent. Therefore, the outcome of the following two expressions will be the same: Expression 1: 5+((1+2)*3-100) Expression 2: 5+{[1+2]*3-100} a) True b) False Q3 Convert the 8-bit binary number 10100110 to decimal, assuming that the binary number is the signed representation (signed magnitude) of the decimal value. a) 166 b) -166 c) -38 d) 38 Q4 Convert the 8-bit binary number 00100110 to decimal, assuming that the binary number is the 2’s complement representation of the decimal value. a) 38 b) -89 c) -88 d) -38 Q5 Convert the fractional binary number 0.1101 to decimal. a) It cannot be expressed exactly in decimal b) 0.8125 c) 0.24016 d) 0.22 Q6 What would be the output of the following set of expressions if someone types it in the Python shell: >>> price = 20 >>> cost = price * 0.2 >>> cost a) 4 b) 4.0 c) There won’t be an output d) 1.82056…
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
Page 4 of 7 Q7 Which of the following variable names is written in pothole case a) my-house b) my_variable c) Price d) cost$ e) more than one option is correct Q8 What would be the output of the following expression if someone types it in the Python shell: >>> -5 % 7 + 3 // -7 * 6 a) -4 b) 24 c) 36 d) 1 Q9 Which of the following is NOT a built-in function in Python a) min b) pow c) sqrt d) abs Q10 What is the first step you should perform when following the Function Design Recipe? a) Test the function b) Write the function’s d escription c) Specify the f unction’s h eader d) Write the function’s usage examples e) Code the f unction’s body Q11 When this Python script is executed, what is bound to y? def area_triangle(base: int, height: int) -> int: return base * height / 2 y = area_triangle(4,2) a) An object of type function. b) 4 c) 4.0 d) The area of a triangle
Page 5 of 7 Q12 This script is typed in the Python Tutor editor. def f(x): x = 2 * x #Line A return x x = 1 x = f(x+1) + f(x+2) Which Python Tutor diagram depicts memory immediately after the assignment state at #Line A is executed for the second time, but before the return x statement is executed? a) b) c) d) Q13 The Python interpreter enforces type annotations: a) True b) False
Page 6 of 7 SECTION 2 (…/6) Answer the question in the space provided on this page. Given the following function header and docstring, complete the function’s body in the space provided def final_grade(final: float, midterm: float, labs: float) -> float: """ Return the final grade of a student in the course. The final is worth 60%, the midterm 20%, and the labs 20%. If the final exam grade is below 50 out of 100, the final grade is the grade of the final exam. Otherwise, the final grade is the weighted addition of all the grades. Preconditions: all input parameters are between 0 and 100. Examples: >>> final_grade(10.5, 5.0, 15.0) 10.5 >>> final_grade(100, 50, 0) 70 >>> final_grade(50, 90, 100) 68 """
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
Page 7 of 7 SECTION 3 (…/6) Answer the question in the space provided on this page. Given the function’s body, complete the function’s header and the docstring in the space provided. def ____________________(_____: int, ______: int) -> ______: return x % y Answer your question here: def ____________________(_____: int, ______: int) -> ______: