EXAMINATION INSTRUCTIONS

Similar documents
EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

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

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

CPSC 121 Sample Final Examination December 2013

READ AND OBSERVE THE FOLLOWING RULES:

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

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

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

UNIVERSITY REGULATIONS

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

UNIVERSITY REGULATIONS

CPSC 311, 2010W1 Midterm Exam #2

CPSC 320 Midterm 2. July 13, 2007

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

Computer Science 304

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

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

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

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

Full Name: CS Account:

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

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

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

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

CS 411 Midterm Feb 2008

CPSC 410 Advanced Software Engineering Mid-term Examination (Term I ): Solution Instructor: Gail Murphy

The University of British Columbia Computer Science 304 Practice Final Examination

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

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

CSE 115. Introduction to Computer Science I

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

CPSC 410? Advanced Software Engineering Mid-term Examination (Term I ) SOLUTION Instructor: Gail Murphy

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

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

CSE 115. Introduction to Computer Science I

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 261: MIDTERM 1 February 14, 2017

UNIVERSITY REGULATIONS

CSE331 Winter 2014, Midterm Examination February 12, 2014

Math 1MP3, midterm test February 2017

CSE373 Winter 2014, Midterm Examination January 29, 2014

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

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

CSE373 Fall 2013, Midterm Examination October 18, 2013

University of Illinois at Chicago Department of Computer Science. Final Examination. CS 151 Mathematical Foundations of Computer Science Fall 2012

CS110 Introduction to Computing Fall 2006 Midterm Exam

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination

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.

CPSC 126 SAMPLE FINAL EXAMINATION ANSWERS April, 2003

CPSC 311, 2011W1 Midterm Exam #2 2011/11/09

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSE 142 Su01 Midterm 1 Sample Solution page 1 of 5

Senior Math Circles Cryptography and Number Theory Week 1

CS 1110 Final Exam May 9th, 2013 SOLUTIONS

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

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

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

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

Announcements. PS 3 is due Thursday, 10/6. Midterm Exam 1: 10/14 (Fri), 9:00am-10:53am

COS 126 General Computer Science Spring Written Exam 1

Microsoft Excel Level 2

Version B Final Exam

CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.

Display Input and Output (I/O)

Problem Points Score Grader Total 75

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

CS143 Final Fall 2009

Lecture 3. Input, Output and Data Types

Activity 1: Introduction

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

CS 455 Midterm Exam 1 Spring 2015 [Bono] Thursday, Feb. 19, 2015

University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I

First Midterm Exam CS164, Fall 2007 Oct 2, 2007

Spring Semester 09 Exam #2 Dr. Dillon. (04/02)

Mobius Institute Board of Certification. Copyright 2011 Mobius Institute Board of Certification All rights reserved

Com S 127x - Lab 6 1. READING FLOWCHARTS WITH CONDITIONAL ACTIONS!

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

COS 226 Fall 2015 Midterm Exam pts.; 60 minutes; 8 Qs; 15 pgs :00 p.m. Name:

: Intro Programming for Scientists and Engineers Final Exam

CSE Theory of Computing Fall 2017 Project 4-Combinator Project

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013

Final Exam. COMP Summer I June 26, points

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Examination in Compilers, EDAN65

Full file at

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG

CS 111X - Fall Test 1

CSE505, Fall 2012, Midterm Examination October 30, 2012

CSI33 Data Structures

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Programming in C++ Indian Institute of Technology, Kharagpur

3. Simple Types, Variables, and Constants

PROBLEM SOLVING 11. July 24, 2012

Spring Semester 13, Dr. Punch. Exam #1 (2/14), form 1 A

COMPUTING SCIENCE 3Z: PROGRAMMING LANGUAGES 3

Transcription:

Midterm exam SAMPLE CSE115 Computer Science I Fall 2018 EXAMINATION INSTRUCTIONS This examination has 9 pages. Check that you have a complete paper. Each candidate should be prepared to produce, upon request, his or her SUNY/UB card. 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 must not be taken from the examination room. Show all of your work in arriving at an answer, unless instructed otherwise. Partial credit will be awarded as appropriate. Candidates are not permitted to ask questions of the invigilators, except in cases of supposed errors or ambiguities in examination questions. CAUTION Candidates guilty of any of the following, or similar, dishonest practices shall be immediately dismissed from the examination and shall be liable to disciplinary action. Making use of any books, papers or memoranda, calculators or computers, audio or visual cassette players, or other memory aid devices, other than those explicitly authorised by the examiners. Speaking or communicating with other candidates. Purposely exposing written papers to the view of other candidates. The plea of accident or forgetfulness shall not be received. --------------------------- DO NOT WRITE BELOW THIS LINE! --------------------------- MODULE 1 Q1 Q2 Q3 Q4 Subtotal TOTAL /20 /20 /20 /20 /80 MODULE 2 Q1 Q2 Q3 Q4 Subtotal /20 /20 /20 /20 /80 /160 1

Midterm exam SAMPLE CSE115 Computer Science I Fall 2018 Module 1 - Question 1 [20 points, 4 points each] The code given below is syntactically correct. 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. keyword 2. variable 3. assignment statement 4. a function call 5. a parameter list def overspent( budget ): over = { months = list( budget.keys() ) months.pop( 0 ) for key in months: 0 data = budget[key] diff = int( data[0] ) - int( data[1] ) if ( diff < 0 ): over[key] = diff return over 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. function whatdoesthisdo(x) { result = ""; if (x < 55) { return "Zoo"; else if (x < 70) { result = "Walk"; x = x - 55; else if (x < 85) { result = "Talk"; x = x - 70; else { result = "Hawk"; x = x - 85; if (x < 5) { result = result + "??"; else if (x < 10) { result = result + "!!"; else if (x < 15) { result = result + "**"; return result; [10 points] What does the following statement print? console.log("answer is "+ whatdoesthisdo(71)); Write your answer below: Answer is Talk?? [10 points] Give a value of x which which whatdoesthisdo(x) returns "Hawk**" Write your answer below: 95, 96, 97, 98, or 99. Any one of these is OK they don t need to give all. 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 convert a temperature from Fahrenheit to Kelvin: Fahrenheit and Kelvin are two common temperature scales. The Fahrenheit scale is used in the United States, while Kelvin is an absolute temperature scale, used worldwide for scientific calculations. While you might think this conversion wouldn't occur much, it turns out there is a lot of scientific and engineering equipment that uses the Fahrenheit scale! Fortunately, it is easy to convert Fahrenheit to Kelvin. Fahrenheit to Kelvin Method #1 1. Subtract 32 from the Fahrenheit temperature. 2. Multiply this number by 5. 3. Divide this number by 9. 4. Add 273.15 to this number. The answer will be the temperature in Kelvin. Source: https://www.thoughtco.com/convert-fahrenheit-to-kelvin-609231 Define a Python function named f_to_k which converts a temperature expressed in degrees Fahrenheit to the equivalent in Kelvin, according to the above method. The function must accept a temperature in Fahrenheit as an argument and return the corresponding temperature in Kelvin. Write your answer below: Here s one possible solution there are others. Any code that solves the problem in the general case is fine: def f_to_k(v): return (v-32) * 5 / 9 + 273.15 4

Module 1 - 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 Consider a function named postage which will be called with one argument (you can assume that it will be called only with an integer value representing the weight of a package, in grams) that computes an integer value representing the postage needed to mail a letter based on its weight, according to the following table: Weight (in grams) Postage (in cents) Up to and including 20 grams 10 More than 20 grams, but less than or equal to 40 grams More than 40 grams 10 + 2 cents per gram of weight over 20 grams 50 + 3 cents per gram of weight over 40 grams Describe briefly what a test case is: Give two distinct test cases: Test case #1: Test case #2: 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. an empty dictionary literal 4. a dictionary lookup def overspent(budget): over = { months = list( budget.keys() ) months.pop( 0 ) for key in months: 0 data = budget[key] diff = int( data[0] ) - int( data[1] ) if ( diff < 0 ): over[key] = diff return over 6

Module 2 - Question 2 [20 points total] Consider a Python function named sumofnumbersinlist which has one parameter. The function will be called with a list of numbers and will return the sum of all the numbers in the list. Part 1 [1 point] What value does sumofnumbersinlist([0]) return? Part 2 [1 point] What value does sumofnumbersinlist([17,3,-5]) return? Part 3 [1 point] What value does sumofnumbersinlist([]) return? 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 Python, the function sumofnumbersinlist: One possible solution: def sumofnumbersinlist(x): sum = 0 for v in x: sum = sum + v return sum 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 JavaScript function named printarray with two parameters. Assume the function will be called with a array of strings and an integer. Define the function so it prints (using console.log) all the strings from the array whose length is greater than or equal to the integer. For example, printarray(["sue", "amy", "bob"], 4) must print nothing, whereas printarray(["foo", "fluffy", "pi", "cake", "rho"], 4) must print the following: fluffy cake Write your answer below: Here s one possible solution there are others. Any code that solves the problem in the general case is fine: function printarray(a, x) { for (var s of list) { if (s.length >= x) { System.out.println(s); 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 mystery(filename): with open(filename, "r", newline='') as f: reader = csv.reader(f) for line in reader: print(line[1]) print("done") mystery("f.csv") Give possible contents for the file f.csv which would cause the above to print: 2 5 8 Done Give your answer below: One possible answer (any with the second column 2, 5, and 8 is OK): 1,2,3 4,5,6 7,8,9 9