cs1301-exam3-fall09-answers

cs1301-exam3-fall09-answers - CS1301 - Exam3 Name: Section...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS1301 - Exam3 Name: Section or 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 10 pages including the title page. Please check to make sure all pages are included. This exam is closed book, closed notes, no calculators. Dont 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. Recursion Fun 5 3. Mystery Code 3 4. Three Lambdas 6 5. Lots-o-Letters 6 6. Skip Every 3 8 7. Factorial 6 8. RedBlend 10 9. BigO Graph 10 Bonus Questions Total: 69 Fall 2009 CS 1301 Exam 3 (cont.) Vocabulary Questions 1. For each of the following vocabulary terms, write a concise 1-2 sentence definition. Be brief, and to the point. (a) (3 points) lambda Solution: A piece of code which can be executed as if it were a function but without a name. (Lambda is also a keyword used to create such an anonymous function.) (b) (3 points) global variable Solution: A global variable is a variable that can be seen (is visible) throught a program module. Defined outside of all functions. (c) (3 points) immutable data type Solution: A (compound) data type in which the elements can not be modified. (d) (3 points) runtime error Solution: An error raised by the python runtime while the program is executing if something goes wrong. For example, a divide by zero error. (e) (3 points) semantic error Solution: An error (in code) that leads to unexpected behavior. The program functions correctly (does what the code says) but the code does not actually perform the action that the programmer intended. Code Understanding Questions 2. (5 points) Write down what would be printed when the following code is executed. def rec(n): if(n<=1): return 1 print n value= rec(n-1) + rec(n-2) return value result = rec(5) 2/ 10 Fall 2009 CS 1301 Exam 3 (cont.) Solution: 5 4 3 2 2 3 2 Grading: 5 points if they get all numbers correct and write them vertically. 4 points if they get all numbers correct, but dont write them vertically. 3 points if they miss only 1 number. 2 points if they get atcorrect, but dont write them vertically....
View Full Document

Page1 / 10

cs1301-exam3-fall09-answers - CS1301 - Exam3 Name: Section...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online