EXAMINATION INSTRUCTIONS

Similar documents
EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

READ AND OBSERVE THE FOLLOWING RULES:

Question Marks 1 /20 2 /16 3 /7 4 /10 5 /16 6 /7 7 /24 Total /100

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

First name (printed): a. DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012

CS 2316 Exam 1 Spring 2014

CPSC 121 Midterm 1 Friday October 14th, Signature: Section (circle one): 11:00 15:30 17:00

CPSC 311, 2010W1 Midterm Exam #2

CPSC 320 Midterm 2. July 13, 2007

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

CPSC 121 Sample Final Examination December 2013

Question Marks 1 /16 2 /13 3 /12 4 /15 5 /8 6 /15 7 /8 8 /5 9 /8 Total /100

UNIVERSITY REGULATIONS

UNIVERSITY REGULATIONS

CPSC 411, 2015W Term 2 Midterm Exam Date: February 25, 2016; Instructor: Ron Garcia

1 Inheritance (8 minutes, 9 points)

CSE 116/504: Spring 2017 Question Samples

Full Name: CS Account:

Question Marks 1 /11 2 /4 3 /13 4 /5 5 /11 6 /14 7 /32 8 /6 9 /11 10 /10 Total /117

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 110: MIDTERM 1 Part B May 26, Important notes about this examination

Computer Science 304

1. The programming language C is more than 30 years old. True or False? (Circle your choice.)

CSE 115. Introduction to Computer Science I

Question Marks 1 /12 2 /6 3 /14 4 /8 5 /5 6 /16 7 /34 8 /25 Total /120

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

CS 1301 Exam 1 Fall 2010

This examination has 11 pages. Check that you have a complete paper.

CSE331 Winter 2014, Midterm Examination February 12, 2014

CS112 Spring 2012 Dr. Kinga Dobolyi. Exam 2. Do not open this exam until you are told. Read these instructions:

CS 111X - Fall Test 1

Midterm Exam 2B Answer key

233 S. Wacker Drive, Suite 3600 Chicago, IL ext

CS Exam 2 Name: Your Grading TA: This exam has 7 pages including the title page. Please check to make sure all pages are included.

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CS 411 Midterm Feb 2008

CSE351 Winter 2016, Final Examination March 16, 2016

Industry Competency Examination Proctor Guide

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSE341 Spring 2017, Final Examination June 8, 2017

ICS 31 UC IRVINE. ############## YOUR UCINET #### K E Y #### ############## Second Midterm YOUR NAME YOUR STUDENT ID (8 DIGITS)

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

Spring Semester 09 Exam #1 Dr. Dillon. (02/19)

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 121: MIDTERM 2 Group March 12, 2014

Functions: Decomposition And Code Reuse

The University of British Columbia Final Examination - December 02, 2014 Mathematics 308. Closed book examination. No calculators.

The University of Oregon May 16, 2015 Oregon Invitational Mathematics Tournament:

UNIVERSITY OF TORONTO Faculty of Arts and Science. Midterm Sample Solutions CSC324H1 Duration: 50 minutes Instructor(s): David Liu.

You may not share any information or materials with classmates during the exam and you may not use any electronic devices.

CS 1301 Exam 1 Fall 2010

CS100 Spring 2017 Final

NATE Exam Administration Script

CSE341 Spring 2016, Midterm Examination April 29, 2016

CPSC 121 Midterm 1 Friday February 5th, Signature: Section (circle one): Morning Afternoon

CS 2316 Exam 1 Spring 2013

Python Activity 5: Boolean Expressions and Selection Statements

Functions: Decomposition And Code Reuse

CS110 Introduction to Computing Fall 2006 Midterm Exam

Exam 2, Form A CSE 231 Spring 2014 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

Exam 2, Form B CSE 231 Spring 2014 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

Midterm CSE 131B Spring 2005

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

CS Name : Grading TA:

University of Washington CSE 140 Introduction to Data Programming Winter Midterm exam. February 6, 2013

CIS 110 Introduction to Computer Programming Summer 2016 Midterm. Recitation # (e.g., 201):

Where The Objects Roam

CSE341 Spring 2017, Final Examination June 8, 2017

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

CSE 131 Introduction to Computer Science Fall Exam I

Howard University School of Law Recommended Policy on Computer Based Exams Presented to the Faculty October 2011

Exam #1, Form 1 A CSE 231 Spring 2015 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am

CIS 110 Introduction to Computer Programming Spring 2016 Midterm

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

Intro. Scheme Basics. scm> 5 5. scm>

Practice Midterm 1. Problem Points Score TOTAL 50

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm

CSE 303, Spring 2005, Midterm Examination 29 April Please do not turn the page until everyone is ready.

Name: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015

CS 111X - Spring Final Exam - KEY

CSE341 Spring 2016, Midterm Examination April 29, 2016

CS 115 Lecture 8. Selection: the if statement. Neil Moore

CSE 131 Introduction to Computer Science Fall Exam I

MATH 253/101,102,103,105 Page 1 of 12 Student-No.:

CS 115 Exam 1, Fall 2015 Thu. 09/24/2015

Spring Semester 10 Exam #1 Dr. Dillon. (02/18)

You may not share any information or materials with classmates during the exam and you may not use any electronic devices.

Dynamic arrays / C Strings

Structure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1

Dalhousie University CSCI 2132 Software Development Winter 2018 Midterm Examination II March 12 15:37-16:24

Final Exam COMP Fall 2004 Dec 16, 2004

CS 2316 Exam 4 Spring 2013

CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam

Compsci 101 Fall 2015 Exam 1 Rubric. Problem 1 (24 points)

CS 1301 Exam 1 Fall 2014

Transcription:

Midterm exam CSE115/503 Computer Science I Spring 2019 EXAMINATION INSTRUCTIONS This examination has 9 pages. If your copy is missing a page, let one of the course staff know. Before starting this test, students should put his or her SUNY/UB card out on the desk so that course staff can check attendance. This examination has 8 questions. Answer all questions. You have 60 minutes to complete this examination. Use your time accordingly. READ AND OBSERVE THE FOLLOWING RULES: Names are pre-printed on the exam booklets. Ensure that you have YOUR exam. Sign, using your usual signature, in the space provided on the back cover. All of your writing must be handed in. This booklet must not be torn or mutilated in any way and cannot leave the examination room. For your answers to earn credit, you must show all of your work in arriving at an answer. Partial credit will be earned as appropriate. Students can talk to proctors only in cases of supposed errors or question ambiguity. Proctors will not answer any other questions during this exam. Candidates guilty of any dishonest practices will be immediately dismissed from the examination and shall be liable for disciplinary action. Examples of dishonest practices include: Having books, papers, calculators, computers, cellphones, or other memory aid or electronic device out without explicit authorization by the proctors. Speaking or communicating with other students. Purposely exposing their work where other students could view it. Claims that the exposure was accidental or due to forgetfulness will not be accepted. --------------------------- DO NOT WRITE BELOW THIS LINE! --------------------------- MODULE 1 MODULE 2 Q1 Q2 Q3 Q4 Subtotal Total /20 /20 /20 /20 /80 Q1 Q2 Q3 Q4 Subtotal /20 /20 /20 /20 /80 /160 1

Midterm exam CSE115/503 Computer Science I Spring 2019 Module 1 - Question 1 [20 points, 4 points each] The code given below is syntactically correct. Circle, and identify by number, EXACTLY 1 example of each of the following items in the code below. If the code below does not contain an example of an item, write no example next to that item in the list. To show you how I want the question answered, the first one is done for you. 0. numeric literal 1. parameter listing 2. variable whose value is a str 3. str literal no example 4. function call 5. boolean expression def countlengths ( lst ) : 1 2 retval = {} for val in lst : strlen = len(val) if strlen in retval : retval[strlen] = retval[strlen] + 1 else : retval[strlen] = 1 return retval 4 5 0 2

Module 1 - Question 2 [20 points total, 10 each part] [ ] 10 points: perfect [ ] 3 points: clearly wrong, some correct elements [ ] 7 points: essentially correct but with small mistakes [ ] 0 points: for anything else Study the following code, then answer the question which follows. def module1question2(param) : retval = 'Char' if param > 128 : return "Extend" if param < 31 : retval = retval + "ctrl " elif param > 122: retval = retval + "punct " if param > 33 or param > 64 : retval = retval + 'p' elif param < 10 : retval = retval + str(param) else : retval = retval + '*' return retval [10 points] What does the following statement print? print(module1question2(19)) Write your answer below: Charctrl * [10 points] Write the statement that calls module1question2 and results in the function returning "Char*". Write your answer below: module1question2(x), where x is 31, 32, or 33 3

Module 1 - Question 3 [20 points total] [ ] 20 points: perfect [ ] 7 points: clearly wrong, some correct elements [ ] 14 points: essentially correct but with small mistakes [ ] 0 points: for anything else Read this description of how to calculate what the end temperature of 1 milliliter of water will be when it starts at 68 degrees and then has energy transferred in to it: In order to calculate the end temperature, we must first calculate how much the water s temperature will change. We do this by calculating the magnitude of the change in Celsius, covert the Celsius result to Fahrenheit, and then add that result to the starting temperature. To get the temperature change in Celsius, we divide the amount of energy transferred in by 4.2. We can then convert that to degrees Fahrenheit by multiply that result by 1.8. Finally, we add 68 to the result to get end temperature of the 1 milliliter of water. Define a Python function named finaltemp which can calculates the end water temperature using the process explained above. Your function should take the amount of energy transferred in as its only input and return the final temperature (in Fahrenheit) of the 1 milliliter of water. Write your answer below: def finaltemp(energy) : deltacelsius = energy / 4.2 deltafahren = deltacelsius * 1.8 finaltemp = deltafahren + 68 return finaltemp 4

Module 1 - Question 4 [20 points total] Consider a function named smarts which will be called with one argument (you can assume that it will be called only with an int value representing a person s IQ score). This function will compute and return a str representing the IQ classification of that individual, according to this table: Age IQ Classification >= 121 Superior >= 111 and < 121 High Average >= 89 and < 111 Average >= 80 and < 89 Low Average >= 69 and < 80 Borderline < 68 Professor Describe briefly what a test case is: [ 8 points total ] [ ] 8 points: perfect [ ] 3 points: clearly wrong, some correct elements [ ] 5 points: essentially correct but with small mistakes [ ] 0 points: for anything else A test case is a possible input together with the corresponding correct output. Give two distinct test cases: [ 12 points total, 6 points each ] [ ] 6 points: perfect [ ] 2 points: clearly wrong, some correct elements [ ] 4 points: essentially correct but with small mistakes [ ] 0 points: for anything else Test case #1: smarts(67) Professor Test case #2: classlevel(140) Superior. ( Winikus would also be acceptable ;) 5

Module 2 - Question 1 [20 points, 4 points each] The code given below is correct: it compiles without errors. I have added some extra spacing to make this question easier to answer. Circle, and identify by number, one and only one example of each of the following items in the code below. If you believe no example exists, write no example next to that item in the list. To show you how I want the question answered, the first one is done for you. 0. numeric literal 1. conditional statement (entire statement) 2. looping statement (entire statement) 3. empty dictionary literal 4. loop header 5. use of a list index no example def countlengths ( lst ) : retval = {} 3 for val in lst : 4 1 2 strlen = len(val) if strlen in retval : retval[strlen] = retval[strlen] + 1 else : retval[strlen] = 1 return retval 0 6

Module 2 - Question 2 [20 points total] Consider a JavaScript function named countlarger which has two parameters. The first parameter is an array of Strings and the second parameter is a Number. The function calculates the number of array entries whose lengths are at least as large as the second parameter. If the array is empty, the function can return 0. Part 1 [1 point] What value does countlarger( [ ], 0 ) return? 0 Part 2 [1 point] What value does countlarger( [ "Short", "Long", "Not Long" ], 5 ) return? 2 ( Short has length of 5 and Not Long has a length of 8) Part 3 [1 point] What value does countlarger( [ "Pat", "Fran", "Joey" ], 2 ) return? 3 Part 4 [17 points] [ ] 17 points: perfect [ ] 6 points: clearly wrong, some correct elements [ ] 12 points: essentially correct but with small mistakes [ ] 0 points: for anything else Define, in JavaScript, the function countlarger: function countlarger(arr, num) { var retval = 0; for (var ent of arr) { if (ent.length >= num) { retval = retval + 1 } } return retval; } 7

Module 2 - Question 3 [20 points total] [ ] 20 points: perfect [ ] 7 points: clearly wrong, some correct elements [ ] 14 points: essentially correct but with small mistakes [ ] 0 points: for anything else Define a Python function named strprefix with two parameters. The first parameter for this function is a List of str and the second parameter is a str. This function will return a new List containing the same number of entries as the first parameter, BUT each entry in the returned List contains the second parameter str added at the start of the entry at the same index in the original List. The original List must not be modified. For example, strprefix(["sign", "neg", "vamp"], "re") would return a new List with: ["resign", "reneg", "revamp"], whereas strprefix(["hz", "ellow", ".Poirot"], "M") must return a new List containing: ["MHz", "Mellow", "M.Poirot"] Write your answer below: def strprefix(lst, prefix) : retval = [] for ent in lst : retval.append(prefix + ent) return retval 8

Module 2 - Question 4 [20 points total] [ ] 20 points: perfect [ ] 7 points: clearly wrong, some correct elements [ ] 14 points: essentially correct but with small mistakes [ ] 0 points: for anything else Study the following code: import csv def last_quest(filename): with open(filename, "r") as f: reader = csv.reader(f) for line in reader: if line[0] == line[1] : print(line[2]) print("done") last_quest("almost.csv") Give possible contents for the file almost.csv which would cause the above to print: I am now Done Give your answer below: skip, or don t, it matters not to me 1, 1, I, more allowed 2, 2, am Consistent, Consistent, now 9