Docsity

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

Toggle sidebar
bg1
Your Name:___________________________________________________
CS FINAL EXAM REVIEW ANSWER
SHEET
FALL 2007
ANSWERS IN RED
Part 1: CONCEPTS AND VOCABULARY
1. What is a tuple? What is the difference between a tuple and a list?
A tuple is a sequence type that is similar to a list. The difference
between a tuple and a list is that tuples are immutable and lists are not.
2. What is the difference between a syntax error, runtime error, and a
semantic error?
A syntax error is the result of a program that is impossible to parse.
A runtime error is an error that occurs while your program is
executing.
A semantic error is the result of a well-formed program that fails to do
what was intended
3. List the comparison operators.
>, <, ==, >=, <=, !=,
4. What is the difference between a local variable and a global
variable?
pf3
pf4
pf5

Partial preview of the text

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

Your Name:___________________________________________________

CS FINAL EXAM REVIEW ANSWER

SHEET

FALL 2007

ANSWERS IN RED

Part 1: CONCEPTS AND VOCABULARY

  1. What is a tuple? What is the difference between a tuple and a list? A tuple is a sequence type that is similar to a list. The difference between a tuple and a list is that tuples are immutable and lists are not.
  2. What is the difference between a syntax error, runtime error, and a semantic error? A syntax error is the result of a program that is impossible to parse. A runtime error is an error that occurs while your program is executing. A semantic error is the result of a well-formed program that fails to do what was intended
  3. List the comparison operators. >, <, ==, >=, <=, !=,
  4. What is the difference between a local variable and a global variable?

Variables located within a function are local variables. Variables located outside of a function are global variables.

Part 2: TRUE OR FALSE

  1. Strings are immutable. T
  2. Programming languages are informal languages that have been designed to express computation. F
  3. Guardians make it possible to prove the correctness of the code. T

Part 3: WRITE A CODE

  1. Make a function makeMovie that takes a 10 frame, gray scale movie with your robot. Assume that Myro is imported and the robot is initialized.

def makeMovie( ): aMovie[ ] for x in range (10): pic= takepicture(ìgrayî) ! add movements here!! aMovies= aMovie + [pic] print ì.î print return aMovie

  1. Using the makeMovie function, write a function playMovie that plays a movie.

def playMovie (aMovie): for pic in aMovie: show (pic) wait(.125) myMovie= makeMovie( ) playMovie(myMovie)

  1. The function copy will copy the contents of an unknown original file into a destination file. Fill in the blanks of the function so that it completes its purpose properly.

def copy(origin, destination): inFile = open(origin, 1. ìrî) outFile = open(destination, 2. ìwî)

fileContents = 3. inFile.read( ) outFile.write( fileContents)

outFile.close( )

  1. inFile.close( ) return(ìAll Doneî)
  2. The function findJpeg will search through folders to find the file that ends with .jpeg (picture) and show the picture. Fill in the blanks of the function so that it completes its purpose properly.

def 1. findJpeg( ): folder=pickAFolder( ) files= os.listdir(2. folder) x= for i in files: if i.endswith("3. .jpeg"): P = makePicture(4. files + "/" +i) show(p) wait(.15) if x == 0: print "No source video"

Part 5: EXTRA CREDIT

  1. What is your section number? Fill in Blank
  2. Create a JavaScript ìHello World!î program.
  1. What company created your Scribbler robot? Parallax Inc.
  2. List 3 Python modules. pydoc, glob, symbol