Docsity

Final Exam with Solution - Introduction to Computing | CS 1301, Exams of Computer Science

Toggle sidebar
bg1
Name:___________________________________________________________________________1/7
CS1301WITHROBOTS,FALL2007‐‐
FINALEXAM
PartI—VocabularyMatching
____6______Mutable
_____5_____Float
_____3_____SyntaxError
______10____Increment
_____14_____Function
_____4_____Integer
_____1_____RuntimeError
____7______Immutable
_____8_____Recursion
_____12_____LinearSearch
_____11_____InsertionSort
_____15_____Parameters
_____13_____Variable
_____9_____Slice
_____2_____SemanticError
1.Anerrorthatoccursduringprogramexecutionthat
preventsitfromcontinuing
2.Theprogramrunssuccessfullybutdoesnotproducethe
intendedoutput
3.Anerrorinthestructureoftheprogramthatmakesit
impossibletointerpret
4.Adatatypethatincludespositiveandnegativewhole
numbers
5.ADatatypethatincludesnumberswithadecimal,or
fractionalparts
6.Acharacteristicwhereelementscanbeassignednew
values
7.Elementscannotbemodified
8.Afunctionthatcallsitselfwhileexecuting
9.Apartofastringgivenbyspecificindices
10.Toincreasethevalueofavariablebyone;usefulin
mostloopingsituations
11.Asortingalgorithmthatbuildsthesortedresultone
elementatatime
12.Asearchingalgorithmthatlooksateveryelementin
sequentialorderuntilitfindsthetargetvalue
13.Anamethatreferstoavalue
14.Anamedsequenceofstatementsthatperformsa
usefuloperation
15.Valuesthatarepassedintoafunctionandassignedto
variables
pf3
pf4
pf5

Partial preview of the text

Download Final Exam with Solution - Introduction to Computing | CS 1301 and more Exams Computer Science in PDF only on Docsity!

CS 1301 WITH ROBOTS, FALL 2007 ‐‐

FINAL EXAM

Part I—Vocabulary Matching

____6______Mutable

_____5_____Float

_____3_____Syntax Error

______10____Increment

_____14_____Function

_____4_____Integer

_____1_____Runtime Error

____7______Immutable

_____8_____Recursion

_____12_____Linear Search

_____11_____Insertion Sort

_____15_____Parameters

_____13_____Variable

_____9_____Slice

_____2_____Semantic Error

  1. An error that occurs during program execution that prevents it from continuing
  2. The program runs successfully but does not produce the intended output
  3. An error in the structure of the program that makes it impossible to interpret
  4. A data type that includes positive and negative whole numbers
  5. A Data type that includes numbers with a decimal, or fractional parts
  6. A characteristic where elements can be assigned new values
  7. Elements cannot be modified
  8. A function that calls itself while executing
  9. A part of a string given by specific indices
  10. To increase the value of a variable by one; useful in most looping situations
  11. A sorting algorithm that builds the sorted result one element at a time
  12. A searching algorithm that looks at every element in sequential order until it finds the target value
  13. A name that refers to a value
  14. A named sequence of statements that performs a useful operation
  15. Values that are passed into a function and assigned to variables

Part II—Writing Code

  1. Write a function called countByTwo that takes two parameters, a (inclusive)and b (exclusive) respectively, and prints from a to b by two’s.

For example, countByTwo(1, 12) would print 1, 3, 5, 7, 9, 11.

def countByTwo(a,b): i=a while i < b: print i i+=

  1. Write a function combineList that returns two lists combined into one.

For example, combineList(aList, bList) would return [4,5,6,1,2,3] if aList=[4,5,6] and bList=[1,2,3].

def combineList(aList, bList): newList= aList + bList return newList

Part III—Interpreting Code

  1. Pretend each of the following statements was entered into the Python interpreter and executed. Write the result of each of the statements below in the adjacent blank.

a = [1, 36, [“Puppy”, “Kitten”], 29, [12.1, 33.3], 21] b = a[2:] c =b[::] d = a[2][0] d = “Dog”

b [['Puppy', 'Kitten'], 29, [12.1, 33.299999999999997], 21]_

c [['Puppy', 'Kitten'], 29, [12.1, 33.299999999999997], 21]_

d ____________________Dog_________________________________________

a[1] _____________________36________________________________________

a[1] + b[1] _______________________65______________________________________

c[‐3] __________________________________29___________________________

d + “house” _______________________Doghouse_________________________________

  1. Consider this block of code:

var1= 15 def foo(): var2= var1= print var

print foo() var2= var2 + 1 print var

What is outputted when the code runs?

12, An error message

  1. Consider the function filterOutEvens. What is returned when the following is executed?

def filterOutEvens(list): newList= [] for element in list: if element % 2 == 0: newList.append(element) return newList

aList = [2, 4, 5, 5, 7, 6, 10] print filterOutEvens(aList)

[2,4,6,10]

Part IV—Extra Credit

  1. Convert the binary number 00101100 to decimal.

44

  1. Represent the hexadecimal number 17 in base ten.

23

  1. What is the name of the main robot in iRobot?

Sonny

  1. What was your favorite aspect of this course?

Answers may vary

  1. What does programming mean to you?

Answers may very