CS 1301 Exam 2 Fall 2013

Similar documents
CS 1301 Exam 3 Spring 2014

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 1 Fall 2011

CS 2316 Exam 4 Fall 2012

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 1 Spring 2014

CS 1301 Exam 3 Fall 2014

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 1 Spring 2011

CS 1301 Exam 2 Spring 2014

CS 1301 Exam 1 Spring 2014

CS 2316 Exam 1 Spring 2013

CS 1301 Exam 2 A Fall 2015

CS 1301 Exam 3 Spring 2012

CS 2316 Exam 1 Spring 2014

CS 1301 Exam 2 Fall 2010

CS 1301 Exam 2 A Fall 2015

CS 1301 Exam 1 Fall 2013

CS 2316 Exam 4 Fall 2011

CS 2316 Exam 4 Fall 2012

CS 1301 Exam 1 Spring 2015

CS 1301 Exam 2 Fall 2014

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.

CS Exam 2 - Spring 2010

CS 1301 Exam 1 Fall 2013

Exam Percentage: / 55 = %

CS Name : Grading TA:

CS 2316 Exam 4 Spring 2013

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

CS 1301 Exam 3 A Spring 2015

CS 2316 Exam 4 Fall 2014

CS 1803 Fall 2010 Exam 1

CS 2316 Exam 3 Fall 2011

CS 2316 Exam 3 Fall 2012

CS 2316 Exam 4 Fall 2011

CS 1803 Fall 2010 Exam 1

CS 1301 Exam 3 Fall 2010

CS 2316 Exam 3 Spring 2013

CS Exam 3 - Spring 2010

CS 2316 Exam 2 Summer 2011

CS 2316 Exam 4 Spring 2012

CS Exam 3 - Spring 2010

CS 1301 Post Exam 3 Practice Spring 2016

CS 2316 Exam 3 Summer 2014

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

CS 1301 Exam 1 Fall 2009

CS 1301 Exam 1 Answers Fall 2009

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

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

Question: Total Points: Score:

Question: Total Points: Score:

CS 110 Exam 2 Spring 2011

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

Question: Total Points: Score:

Instructor: Yu Wang 11/16/2012

Question: Total Points: Score:

CS 190 Exam 1 Fall 2010

CS 110 Exam 1 Fall 2011

Question: Total Points: Score:

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

Question: Total Points: Score:

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

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

CS 190 Exam 2 Fall 2014

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

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

CS 111X - Fall Test 1

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

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

Place your name tag here

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

Question: Total Points: Score:

Question: Total Points: Score:

CS 1316 Exam 1 Summer 2009

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

CS 155 Exam 2 Spring 2015

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

Question: Total Points: Score:

Question: Total Points: Score:

Question: Total Points: Score:

Question: Total Points: Score:

Section 004 Spring CS 170 Exam 1. Name (print): Instructions:

Section 002 Spring CS 170 Exam 1. Name (print): Instructions:

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

CS 110 Exam 2 Fall 2011

: Intro Programming for Scientists and Engineers Final Exam

Question: Total Points: Score:

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

CS 1322 Test 2 - Version 1 Tuesday June 24 th

CS 1316 Exam 2 Fall 2009

All program statements you write should be syntactically correct. Partial credit is not guaranteed with incorrect use of syntax.

Problem Score Max Score 1 Syntax directed translation & type

Question: Total Points: Score:

CS170 (005): Introduction to Computer Science Exam 2

CS 1316 Exam 3 Fall 2009

CS 1316 Exam 2 Summer 2009

(the bubble footer is automatically inserted into this space)

Structure and Interpretation of Computer Programs

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

Transcription:

CS 1301 Exam 2 Fall 2013 Name : Section TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in compliance with the Academic Honor Code of Georgia Tech. Do NOT sign nor take this exam if you do not agree with the honor code. Devices: If your cell phone, pager, PDA, beeper, ipod, or similar item goes off during the exam, you will lose 10 points on this exam. Turn all such devices off and put them away now. You cannot have them on your desk. Academic Misconduct: Academic misconduct will not be tolerated. You are to uphold the honor and integrity bestowed upon you by the Georgia Institute of Technology. Keep your eyes on your own paper. Do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than a proctor for ANY reason in ANY language in ANY manner. Do NOT share ANYTHING during the exam. (This includes no sharing of pencils, paper, erasers). Follow directions given by the proctor(s). Stop all writing when told to stop. Failure to stop writing on this exam when told to do so is academic misconduct. Do not use notes, books, calculators, etc during the exam. Time: Don t get bogged down by any one question. If you get stuck, move on to the next problem and come back once you have completed all of the other problems. This exam has 5 questions on 8 pages including the title page. Please check to make sure all pages are included. 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. I have also read and understand the requirements outlined above. Signature: 1

Question Points Score 1. Vocabulary 9 2. Multiple Choice 15 3. Fudz! 4 4. List Questions 6 5. Grid 12 Total: 46 1. (9 points) For each of the following vocabulary terms, write a concise 1-2 sentence definition. Be brief, and to the point. (a) [3 pts] variable Solution: A name (more specificaly, an identifier) that refers to a value. (b) [3 pts] local variable Solution: A local variable is a variable that can only be seen (is visible) within the function that defined it. Once the function returns, the local variable is lost. (c) [3 pts] global variable Solution: A global variable is a variable that can be seen (is visible) throught a program module. Defined outside of all functions. 2. (15 points) For each of the following multiple choice questions, indicate the most correct answer by circling it! (a) [1 pt] What happens when you try to keep reading lines after you ve hit the end of the file? A. You get an EndOfFile error B. You get an empty string. C. The file loops back to the top and starts reading again. D. You start getting junk data from the places in memory that come after the file. E. None of the above (b) [1 pt] What is the type of the data stored in X after this line of code is executed? X = print("2.0") A. String B. Int C. Float D. Bool E. NoneType 2

(c) [1 pt] Given the following code, what is printed? print( list( range(1, 10, 2) ) ) A. [2, 4, 6, 8, 10] B. [2, 4, 6, 8] C. [1, 3, 5, 7, 9, 10] D. [1, 3, 5, 7, 9] E. None of the above (d) [1 pt] What happens when the following code is ran? x = 20 if x < 17: print("it s less than 17!") elif x = 17: print("it s equal!") else: print("it s greater than 17!") A. prints: It s less than 17! B. prints: It s equal! C. prints: It s greater than 17! D. Nothing is printed E. A syntax error is generated (e) [1 pt] Given the following code, what is printed when it executes? p = "foo" temp = "" temp2 = "" for x in range(len(p)): for y in range(len(p)): temp = temp + p[x] temp2 = temp2+p[y] print(temp2) A. fffooo B. fffoooooo C. foofoofoo D. oofoofoof E. None of the above (f) [1 pt] A comment line in Python is began by which symbol or symbol combination? A. $ B. // C. <-- D. # E. None of these. (g) [1 pt] Convert 110110 2 to decimal (base 10): A. 29 B. 52 C. 53 D. 54 E. 118 3

(h) [1 pt] Convert 171 10 to binary (base 2): A. 01000011 B. 10000011 C. 01000111 D. 11001101 E. 10101011 F. 01010101 (i) [1 pt] Which of the following can only represent integer values between 0 and 255? A. bit B. byte C. pixel D. int E. None of these (j) [1 pt] Use this code to answer the next three questions: x = 2 mytuple = ( "hello", 15, [1, "cs1301"], x) What is the value of mytuple[3] if we execute x=5? A. 5 B. 2 C. "cs1301" D. x E. A TypeError occurs. (k) [1 pt] What is the value of mytuple if we execute mytuple[2] = 3 A. ( "hello", 15, 3, x) B. ( "hello", 15, [3], 2) C. ( "hello", 15, 3, 2) D. ("hello", 15, [3], x) E. A TypeError occurs. (l) [1 pt] What is the value of mytuple if we execute mytuple[2][1] = mytuple[0] A. ("hello", 15, [1, "hello"], 2) B. ("hello", 15, ["hello"], 2) C. ("hello", 15, [1, "hello"], x) D. ("hello", 15, ["hello"], x) E. A TypeError occurs. (m) [1 pt] (3) is an example of a tuple. A. True B. False (n) [1 pt] 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. (o) [1 pt] 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. 4

3. (4 points) Examine the following code: def fudz(n): if n <= 2: return 1 print("nom" * n) return fudz(n-1) + fudz(n//2) result = fudz(4) Write down what it would print. Also write down what the result variable would refer to after the code is executed. Solution: nomnomnomnom (4 noms) nomnomnom (3 noms) result is: 3 Grading: +1 for 4 noms first +1 for 3 noms second +2 for knowing result is 3. 4. (6 points) Examine the following code: a = [1, 2, 4] b = a b[0] = 9 a[1] = "cabc" c = a[:] c[2] = b[1] After the code executes, what does each of the variables point at? a - b - c - 5

Solution: A: [9, cabc, 4] B: [9, cabc, 4] C: [9, cabc, cabc ] Grading: +2 for each correct line. 6

5. (12 points) Write a function drawgrid which takes a picture object as a parameter. Your drawgrid function should draw black lines horizontally and vertically every 20 pixels. (i.e. each vertical line should be seperated by 19 non-black pixels, and every horizontal line should be seperated by 19 non-black pixels) Example function call: >>> p = takepicture() >>> drawgrid(p) >>> show(p) Solution: def drawgrid(p): height = getheight(p) width = getwidth(p) #Draw horizontal lines. for y in range(0,height,20): for x in range(width): pix = getpixel(p,x,y) setrgb(pix, (0,0,0) ) #Draw vertical lines for x in range(0,width,20): for y in range(height): pix = getpixel(p,x,y) setrgb(pix, (0,0,0) ) Grading: +1 for correct header. +2 for getting the height/width of the image. +2 for stepping by 20 in some form of iteration. 7

+1 for coloring any pixel black. +2 for drawing (any) complete vertical line. +2 for drawing (any) complete horizontal line. +2 for correctly drawing all of the grid. (-1 if they return something other than none) (-1 if they use makepicture or takepicture or copypicture instead of working on the picture that was passed in.) 8