CS 1301 Exam 2 A Fall 2015

Similar documents
CS 1301 Exam 2 A Fall 2015

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 1 Fall 2011

CS 1301 Exam 3 Spring 2014

CS 1301 Exam 2 Fall 2010

CS 1301 Exam 3 A Spring 2015

CS 1301 Exam 1 Fall 2010

CS 2316 Exam 1 Spring 2013

CS 2316 Exam 4 Fall 2012

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 3 Spring 2012

CS 1301 Exam 2 Spring 2014

CS 1301 Exam 3 Fall 2010

CS 1301 Exam 2 Fall 2013

CS 1301 Exam 2 Fall 2014

CS 1301 Exam 1 Spring 2014

CS 2316 Exam 1 Spring 2014

CS 1301 Exam 1 Fall 2013

CS 1301 Exam 1 Spring 2014

CS 2316 Exam 4 Fall 2011

CS 1301 Exam 1 Fall 2013

CS 1301 Exam 1 Spring 2011

CS 1301 Exam 1 Fall 2009

CS 1301 Exam 3 Fall 2014

CS 2316 Exam 4 Fall 2014

CS 1301 Exam 1 Answers Fall 2009

CS 2316 Exam 4 Fall 2012

CS Name : Grading TA:

CS 1301 Exam 1 Spring 2015

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

CS 2316 Exam 3 Fall 2011

CS 2316 Exam 4 Spring 2013

Exam Percentage: / 55 = %

CS 1803 Fall 2010 Exam 1

CS 1803 Fall 2010 Exam 1

CS 2316 Exam 4 Fall 2011

CS 2316 Exam 3 Spring 2013

CS Exam 2 - Spring 2010

CS 2316 Exam 2 Summer 2011

CS 2316 Exam 3 Fall 2012

CS 2316 Exam 4 Spring 2012

CS 1301 Post Exam 3 Practice Spring 2016

CS Exam 3 - Spring 2010

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

CS Exam 3 - Spring 2010

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 2316 Exam 3 Summer 2014

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

Question: Total Points: Score:

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

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

CS 190 Exam 1 Fall 2010

CS 110 Exam 2 Spring 2011

Question: Total Points: Score:

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

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

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

CS 155 Exam 2 Spring 2015

Instructor: Yu Wang 11/16/2012

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

Question: Total Points: Score:

CS 190 Exam 2 Fall 2014

Question: Total Points: Score:

Question: Total Points: Score:

Question: Total Points: Score:

Question: Total Points: Score:

CS 110 Exam 1 Fall 2011

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

Question: Total Points: Score:

Question: Total Points: Score:

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

Place your name tag here

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 111X - Fall Test 1

Question: Total Points: Score:

Question: Total Points: Score:

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

Question: Total Points: Score:

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

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

CS 1322 Test 2 - Version 1 Tuesday June 24 th

: Intro Programming for Scientists and Engineers Final Exam

CS 110 Exam 2 Fall 2011

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

Question: Total Points: Score:

Question: Total Points: Score:

CS 1301 CS1 with Robots Summer 2007 Exam 1

Structure and Interpretation of Computer Programs

Structure and Interpretation of Computer Programs

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

CS170 (005): Introduction to Computer Science Exam 2

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

Your Name: Your TA's Name: 1 / 10 CS 1301 CS1 with Robots Fall 2008 Exam 3

CS 1316 Exam 2 Summer 2009

CS 111X - Spring Final Exam - KEY

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

Short Answer Questions (40 points)

University of California, Berkeley College of Engineering

Transcription:

CS 1301 Exam 2 A Fall 2015 Name : Grading 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 7 questions on 7 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 1. Vocabulary 9 2. MysteryLists 5 3. Multiple Choice 5 4. OnlyAs 10 5. World Cup 4 6. Seek Light 8 7. Create Usernames 12 Total: 53 Points Score 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] compound data type A data type that can hold primitive data types, such as a list, tuple, or dictionary. (b) [3 pts] local variable 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] type conversion An explicit function call that takes a value of one type and computes a corresponding value of another type. (Function call, converts from one type to another type, must be explicitly called.) 2. (5 points) Imagine that you are the python interpreter and execute the following code. Next to the code, write down exactly what it prints. Draw a box around your answer. def mystery(alist): if (len(alist) == 0): return [] else: mystery(alist[1:]) 2

print(alist[1:]) a = [4,7,9,[6,7]] b = a[:] b[3][1] = 0 mystery(a) Printed: [] [[6, 0]] [9, [6, 0]] [7, 9, [6, 0]] Grading: 1 pt - For largest printout, e.g. [7,9,[6,X]] (Ignore 7 vs 0 issues) 1 pt - For the [9, [6,X] ] immediately before/after the longest printout. 1 pt - Answer in correct order (empty list first, longest list last) 1 pt - Empty list printed at either top or bottom. 1 pt - for [6,0] in nested list in all places it appears. 3. (5 points) For each of the following multiple choice questions, indicate the most correct answer by circling it! (a) [1 pt] Which of these commands is NOT a valid robot function? A. beep(1,4400) B. showname() C. takepicture() D. forward(1,1) E. turnleft(1,2) (b) [1 pt] Convert 11011001 2 to decimal (base 10): A. 217 B. 225 C. 232 D. 233 E. 234 (c) [1 pt] Convert 171 10 to binary (base 2): A. 01000011 B. 10000011 C. 01000111 D. 11001101 E. 10101011 F. 01010101 (d) [1 pt] Grace Hopper was: A. A Rear Admiral. B. Awarded the man-of-the-year award from DPMA in 1969. C. Instrumental in the development of COBOL. D. Credited for developing the first compiler. E. All of these. (e) [1 pt] In 1964, Douglas Engelbart demonstrated the worlds first: A. Transistorized Computer B. Mouse C. Tape Drive D. Vacuum Tube E. Solid Sate Memory 3

4. (10 points) The function below accepts a file name (as a string) and writes every line in that file that begins with a capital letter A to a new file named newfile.txt. Fill in the blanks appropriately: def onlyas(filename): inf = (, ) outf = (, ) lines = inf. for line in lines: if : outf. inf.close() outf.close() def onlyas(filename): inf = open( filename, "r") outf = open( "newfile.txt", "w") lines = inf.readlines() for line in lines: if line[0] == "A": #or line.startswith("a") outf.write(line) inf.close() outf.close() Grading: 1 point for each correctly filled in blank, with the exception of the if conditional. They get +2 points if that one is correct, +1 if it is close to correct. 4

5. (4 points) Pretend that you are the python interpreter. Execute the following code and write what it prints out beside the code. If you have any other work on the page, draw a box around your answer. worldcup = {"Messi":(10, 4), "Ronaldo":(14, 1), "Muller":(10, 5), "Neymar":[11, 4], "Rodriguez":(14, 6), "Cuadrado":(4, 1)} goals = 0 attempts = 0 player1 = "" player2 = "" for k in worldcup: if worldcup[k][1] > goals: goals = worldcup[k][1] player1 = k if worldcup[k][0] > attempts: attempts = worldcup[k][0] player2 = k print(player1, goals) print(player2, attempts) Line1: Rodriguez 6 Line2: Ronaldo 14 (Also Possible: Rodriguez 14) Grading: 1 pt - Rodriguez on first line. 1 pt - 6 on first line. 1 pt - Ronaldo on 2nd line (or Rodriguez). 1 pt - 14 on 2nd line. 5

6. (8 points) Write a function named seeklight that accepts an integer as a parameter. The integer corresponds to how long your function should run, in seconds, before returning. While running, your function should get the value of the robots center light sensor (using a getlight( center ) call). If the value returned is smaller than 500, your robot should move forward at full speed for one second. If the light sensor value is larger than (or equal to) 500, the robot should beep at 800Hz for 1 second, and not move. Make sure that, no matter what, your robot stops and the function returns when the time is up! You may assume that the Myro library is already loaded and that your robot is already connected (init has been called) to the computer. When your function returns, it should return None. def seeklight(time): for t in timer(time): if getlight("center") >= 500: beep(1,800) else: forward(1,1) Grading: 1 point for correct header 1 point for running N seconds 1 point for checking the getlight sensor each iteration 2 points for moving forward when triggered 2 points for beeping when not triggered (-2 points (instead of -4) if they reverse the beep and move) 1 point for function returning (None) when the time is up. Misc Penalties: -1 if doesn t stop at end of function. -1 mixing-up time and frequency parameters beep(800,1) 6

7. (12 points) Write a function called createusernames that accepts three lists as parameters. The first parameter will contain strings which contain first names. The second parameter will be a list of strings that contain last names. The third list will contain integers. The function should combine each item in the lists to create a username. A username is made up of the first letter of the first name, up to the first six letters of the last name, and the digit. Note that if a last name has less than six letters the entire last name will be used. Your funciton should return a list of usernames in the same order as the input data. You may assume that all three lists are of the same length. For example: >>> results = createusernames(["glenn","ikenna"], ["HollingsWorth","Omekam"], [7,3] ) >>> print( results ) [ GHollin7, IOmekam3 ] def createuusername(alist, alist2, alist3): newlist = [] for index in range( len(alist) ): string = alist[index][0] + alist2[index][:6] + str(alist3[index]) newlist.append(string) return newlist Grading: 1pt - Correct def statement 2pts - uses only first initial of first name. 2pts - Uses up to 6 characters of last name. (-1 if they only grab 5 characters instead of six...) 2pts - Converts digit to a string. 2pts - concatenates each item the resulting username string. 2pts - Adds each username to a list. 1pt - returns the list of usernames. 7