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.

Similar documents
CS 1301 Exam 2 Fall 2013

CS 1301 Exam 1 Spring 2011

CS 1301 Exam 1 Fall 2009

CS 1301 Exam 1 Fall 2011

CS 1301 Exam 1 Answers Fall 2009

CS 2316 Exam 1 Spring 2013

CS 2316 Exam 1 Spring 2014

This exam has 10 pages including the title page. Please check to make sure all pages are included.

CS 1301 Exam 3 Spring 2014

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 1 Spring 2015

CS 1301 Exam 1 Fall 2013

CS 1301 Exam 1 Fall 2010

CS Name : Grading TA:

CS 1301 Exam 1 Spring 2014

CS 1301 Exam 1 Fall 2013

CS 1301 Exam 2 A Fall 2015

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 2 Fall 2010

CS 1301 Exam 2 A Fall 2015

CS 1301 Exam 1 Spring 2014

CS 1301 Exam 2 Spring 2014

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 3 Spring 2012

CS 2316 Exam 4 Spring 2013

CS 1301 Exam 3 Fall 2014

CS 1301 Exam 2 Fall 2014

CS 1803 Fall 2010 Exam 1

CS 2316 Exam 4 Fall 2012

CS 2316 Exam 3 Spring 2013

CS 1301 Exam 3 A Spring 2015

Exam Percentage: / 55 = %

Question: Total Points: Score:

CS 2316 Exam 4 Fall 2011

CS 2316 Exam 4 Fall 2014

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

CS 2316 Exam 4 Fall 2012

CS 1803 Fall 2010 Exam 1

CS 1301 Post Exam 3 Practice Spring 2016

CS Exam 2 - Spring 2010

CS 2316 Exam 3 Fall 2011

CS Exam 3 - Spring 2010

CS 110 Exam 1 Fall 2011

CS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions:

CS Exam 3 - Spring 2010

CS 2316 Exam 4 Fall 2011

CS 2316 Exam 3 Fall 2012

Question: Total Points: Score:

Instructor: Yu Wang 11/16/2012

Your (printed!) Name: CS 1803 Exam 3. Grading TA / Section: Monday, Nov. 22th, 2010

CS 2316 Exam 4 Spring 2012

Place your name tag here

CS 1316 Exam 2 Summer 2009

CS 1301 Exam 3 Fall 2010

CS 170 Exam 2. Version: A Spring Name (as in OPUS) (print): Instructions:

Question Possible Points Earned Points Graded By GUI 22 SQL 24 XML 20 Multiple Choice 14 Total Points 80

CS 1316 Exam 1 Summer 2009

Section 003 Fall CS 170 Exam 1. Name (print): Instructions:

Section 003 Fall CS 170 Exam 2. Name (print): Instructions:

Question: Total Points: Score:

Question: Total Points: Score:

CS 2316 Exam 2 Summer 2011

CS 170 Exam 2. Version: A Spring Name (as in OPUS) (print): Instructions:

Question: Total Points: Score:

CS 155 Exam 2 Spring 2015

CS150 Sample Final. Name: Section: A / B

Question: Total Points: Score:

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

EXAMINATION INSTRUCTIONS

CS 111X - Fall Test 1

Question: Total Points: Score:

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print):

Question: Total Points: Score:

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print):

CS 190 Exam 1 Fall 2010

CS 2316 Exam 3 Summer 2014

CS 170 Exam 1. Version: B Fall Name (as on OPUS):

Question: Total Points: Score:

CS 110 Exam 2 Spring 2011

CS 170 Exam 1. Version: C Fall Name (as on OPUS):

CS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, Good Luck!

CS 2316 Learning Objectives

CS150 Sample Final Solution

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

Spring 2017 CS 1110/1111 Exam 1

CS 1316 Exam 3 Fall 2009

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

CS 190 Exam 2 Fall 2014

Overview of List Syntax

CMSC 330, Fall 2018 Midterm 1

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

MUTABLE LISTS AND DICTIONARIES 4

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Question: Total Points: Score:

CPE Summer 2015 Exam I (150 pts) June 18, 2015

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Question: Total Points: Score:

Your (printed!) Name: CS 1803 Exam 2. Grading TA / Section: Monday, Oct 25th, 2010

Version B Final Exam

CS 1301 CS1 with Robots Summer 2007 Exam 1

Transcription:

CS1301 - Exam 2 Name: Your Grading TA: Instructions: Please write clearly. What I cannot read, I will not grade. Show all your work in detail. I give partial credit. This exam has 7 pages including the title page. Please check to make sure all pages are included. This exam is closed book, closed notes, no calculators. Don t get bogged down on any one question. You will have 50 minutes to complete this exam. I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. Signature: Question Points Score 1. Vocabulary 15 2. Multiple Choice 5 3. Types of Reading 6 4. DooWaa 6 5. Mystery Code 3 6. traincrash 5 7. Breakup 7 8. Stick Together 9 Total: 56 Spring 2010

1. For each of the following vocabulary terms, write a concise 1-2 sentence definition. Be brief, and to the point. (a) (3 points) dictionary A mutable compound data type that associates keys with values. (b) (3 points) slice A subsequence copied from a sequence specified by a range of indices. The slice operator is: sequence[start:stop]. (c) (3 points) traverse To move through all elements of a set, performing a similar operation on each element. (d) (3 points) mutable type mutable type - A data type in which the elements can be modified. All mutable types are compound types. Lists are mutable data types; strings are not. (e) (3 points) decrement decrement - The process of decreasing a variable, typically by one. avar = avar - 1 Multiple Choice 2. For each of the following questions, select the appropriate answer by circling it. (a) (1 point) Order the following items from earliest (older) to latest (newer): 1. Konrad Zuse s Z1 computer 2. The Transistor 3. ARPANET A. 1,2,3 B. 2,3,1 C. 1,3,2 D. 2,1,3 E. None of these. (b) (1 point) Order the following items from earliest (older) to latest (newer): 1. The Jacquard Loom 2. Ada Lovelace s program for the Analytical Engine 3. Jacques De Vaucanson s Digesting Duck A. 1,2,3 B. 3,1,2 C. 2,3,1 D. 2,1,3 E. None of these. (c) (1 point) Which of these would you use to print a number to four decimal places? A. %4i B. 0%.4i C. %4f D. %.4f E. %0.5f 2/ 7 Spring 2010

(d) (1 point) Convert 11011001 2 to decimal (base 10): A. 217 B. 225 C. 232 D. 233 E. 234 (e) (1 point) Which data type is mutable? A. int B. float C. str D. list E. tuple Short Answer 3. Three functions for reading from a file are read(), readline(), and readlines(). Briefly explain what each of these functions returns when called. Be sure to explain how each function differs in behavior. (a) (2 points) read() - read() - This function returns a string that contains the entire contents of the file. (b) (2 points) readline() - readline() - This function contains a string that contains only the first line of the file. (all characters up to, and including, the first newline character, denoted by a \n). (c) (2 points) readlines() - readlines() - This function returns a list that contains each line in the file as a string. Code Understanding 4. (6 points) Fill in the blanks so that, when run, the code below will output the followng: >>> func1() DooWaa Diddy Diddy Dum Diddy Doo def func1(): print "DooWaa" for i in range( ): print if i == : 3/ 7 Spring 2010

print "Dum" print "Doo" def func1(): print "DooWaa" for i in range( 3 ): print "Diddy" if i == 1 : print "Dum" print "Doo" Grading: 2 points for each correct blank. -1 for any minor syntax errors. (leaving out quotes, etc) 5. (3 points) def mysteryfunc(x,y): # x and y are non-negative integers if y == 0: return 0 else: return x + mysteryfunc(x,y-1) What does this mystery function do? Also tell us the value returned as a result of calling mysteryfunc(5,2) Answer: This function multiples the two arguments by using repeated addition. The number 10 proves they know how the function works. Grading: 3 points if they understand what it does, and give us the correct answer 2 points if they describe some of what it does, but give us the wrong number. 1 point if they mention recursion, but don t give the correct answer. 0 points for anything else/less. 6. Examine the following code: def traincrash (x): while x <= 10: if x % 5 == 0: return "oh no, Crash!" if x % 3 == 0: 4/ 7 Spring 2010

print "I m a train..." x = x +1 print "Choo-choo!" return "I m too tired to go on" If this code is called from the IDLE window as follows: y = traincrash(8) (a) (3 points) What is displayed on the screen? Choo-choo! I m a train... Choo-choo! Grading: 1 point for each correct line, -1 point for each extra line (b) (2 points) What will be stored in the y variable from the example function call above? oh no, Crash! Grading: 2 points for the string stored in y. 5/ 7 Spring 2010

Code Writing Questions 7. (7 points) Breakup - Write a function called breakup that accepts a string as a parameter. It should return a list which is made up of single character strings, one per letter in the original string. For example: >>> result = breakup( "Yey excellence fees!" ) >>> print result [ Y, e, y,, e, x, c, e, l, l, e, n, c, e,, f, e, e, s,! ] def breakup(astring): alist = [] for letter in astring: alist.append(letter) return(alist) Grading: 1pt - Correct def statement 2pt - traverses the string 2pt - adds each letter to the list 2 pt - returns new list 6/ 7 Spring 2010

8. (9 points) Stick Together - Write a function called sticktogether that accepts a list as a parameter. It should return a string that is the concatenation of all string elements in the list. Note that non-string elements should be skipped, including nested lists. For example: >>> result = sticktogether( [ 4, "Hello", ["bob",3], " ", True, "There!", 7] ) >>> print result "Hello There!" def sticktogether(alist): astring = "" for item in alist: if type(item) == type( letters ): astring = astring + item return(astring) # or: if type(item) == str: Grading: 1pt - Correct def statement 2pt - traverses the items in the list 2pt - checks the type of each item. 2pt - concatenates each item of type string to the string. 2pt - returns the string. 7/ 7 Spring 2010