CS 1301 Exam 1 Answers Fall 2009

Similar documents
CS 1301 Exam 1 Fall 2009

CS 1301 Exam 2 A Fall 2015

CS 1301 Exam 2 A Fall 2015

CS 1301 Exam 1 Fall 2014

CS 1301 Exam 1 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 1301 Exam 1 Fall 2010

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

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 1 Spring 2015

CS 1301 Exam 1 Spring 2014

CS 1301 Exam 1 Spring 2014

CS 2316 Exam 1 Spring 2013

CS 1301 Exam 1 Fall 2011

CS 1301 Exam 1 Fall 2013

CS 1301 Exam 2 Fall 2013

CS 1301 Exam 1 Fall 2013

CS Name : Grading TA:

CS 1803 Fall 2010 Exam 1

CS 1301 Exam 1 Spring 2011

CS 1301 CS1 with Robots Summer 2007 Exam 1

CS 1301 Exam 2 Fall 2010

CS 2316 Exam 1 Spring 2014

Question: Total Points: Score:

CS 1301 Exam 3 Spring 2014

Exam Percentage: / 55 = %

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

CS 1301 Exam 2 Spring 2014

CS 1301 Exam 2 Fall 2014

CS 1803 Fall 2010 Exam 1

Conditionals and Recursion. Python Part 4

CS 1316 Exam 1 Summer 2009

CS 111X - Fall Test 1

CS 1301 Exam 3 Spring 2012

CS 2316 Exam 4 Spring 2013

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

CS 1301 Exam 3 Fall 2014

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

CS 1316 Exam 2 Summer 2009

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

CS 2316 Exam 3 Fall 2011

CS 2316 Exam 4 Fall 2011

Question: Total Points: Score:

CS 2316 Exam 4 Fall 2012

CS 190 Exam 2 Fall 2014

CS 1301 Exam 3 A Spring 2015

Question: Total Points: Score:

CS 2316 Exam 4 Fall 2012

Decisions, Decisions. Testing, testing C H A P T E R 7

Reviewing all Topics this term

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

CS Exam 3 - Spring 2010

Question: Total Points: Score:

Act like a code monkey Coding Basics

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

cs1114 REVIEW of details test closed laptop period

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT

CS Exam 2 - Spring 2010

ENGR 101 Engineering Design Workshop

Conditional Expressions and Decision Statements

CS 2316 Exam 4 Fall 2014

CS 2316 Exam 3 Spring 2013

Computer Components. Software{ User Programs. Operating System. Hardware

CS 1301 Final Exam Review Guide

Python: common syntax

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

Question: Total Points: Score:

CS 1316 Exam 2 Fall 2009

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

Question: Total Points: Score:

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

Question: Total Points: Score:

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

CS 2316 Exam 4 Fall 2011

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

BASIC ELEMENTS OF A COMPUTER PROGRAM

CS 1316 Exam 3 Fall 2009

Place your name tag here

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

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

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

1/11/2010 Topic 2: Introduction to Programming 1 1

CS 1301 Post Exam 3 Practice Spring 2016

CS Exam 3 - Spring 2010

CS1114 Spring 2015 Test ONE ANSWER KEY. page 1 of 8 pages (counting the cover sheet)

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

CS 110 Exam 1 Fall 2011

CSC326 Python Imperative Core (Lec 2)

1 Truth. 2 Conditional Statements. Expressions That Can Evaluate to Boolean Values. Williams College Lecture 4 Brent Heeringa, Bill Jannen

CIS192 Python Programming. Robert Rand. August 27, 2015

2. Explain the difference between read(), readline(), and readlines(). Give an example of when you might use each.

The current topic: Python. Announcements. Python. Python

QUIZ: Generations of computer technology. Hardware:

Question: Total Points: Score:

Conditionals: Making Choices

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

Algorithms and Programming I. Lecture#12 Spring 2015

CS 2316 Exam 3 Fall 2012

Transcription:

Page 1/6 CS 1301 Fall 2009 Exam 1 Your Name: 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. CS 1301 Exam 1 Answers Fall 2009 Problem Earned Points Possible Points 1. Vocabulary 18 2. Python Expressions 26 3. Fill in the Blank 11 4. Multiple Choice 6 5. Reading Code 5 6. Combinations 5 7. MovieView 6 8. IsEven 5 9. Blastoff 8 10. Count J's 10 Total: 100

Page 2/6 CS 1301 Fall 2009 Exam 1 Your Name: 1. Vocabulary (18 points) For each of the following words, write a 1-2 sentence definition of the word as used in this class. Your definition should be concise and to the point, while proving you know what the term means. a) evaluate - To calculate the value of an expression. b) iteration - To repeatedly execute a block of code. c) modulus - % operator, that calculates the remainder of an integer division. d) proprioception - on a robot, internal sensing mechanisms. On a human, a sense of the relative positions of different parts of ones own body. e) semantic error - An error that makes a program behave differently than intended by the programmer, but does not actually generate a syntax or runtime error. f) type conversion - Deliberately changing the type of a value, using a function such as int(), str(), or float(). 3 points if the definition is very good, 2 points if they mostly got the concept, 1 point if they included a few of the right keywords, and zero if they get it completely wrong. 2. Python Expressions (26 points) Act like the python interpreter and evaluate the following expressions. Write what value the expressions evaluate to as well as its type (integer, float, string, boolean, etc...). Expression Evaluated Result (1 points) Type of the Result (1 point) Hello + World +! HelloWorld! String 5 + 6 11 Int cs1301 * 2 cs1301cs1301 String int( 5.9) / 3 1 Int ( 6.0 1) ** 2 + 3 28.0. Float 92 + str(34) + Four 9234Four String True and ( 3!= 2) True. Boolean range(3,7) [3,4,5,6] List (7.0 + 6 ) / 2 6.5 Float range(3,10,2) [3,5,7,9] List 5.0 > 5.0 False. Boolean Pumpkin %.3f % 3.1459 "Pumpkin 3.146" String 7 + 3 / 2 > 8 False. Boolean (raw_input() > 3) and False False. Boolean

Page 3/6 CS 1301 Fall 2009 Exam 1 Your Name: 3. Fill in the Blank (11 points) The name of my grading TA is: <Appropriate Name> and I am in section _<SECTION>. For homeworks 2 & 3 my partner was: <NAME>. In Python, a = is used for assignment_, while a == is used for equivalence checking. When a function calls itself, it is said to be Recursive / Recursion. In python, the if keyword is used to make a conditional_ statement, while the for and while keywords are used to make loops (1/2 point: iteration). The decimal (base 10) number { 43 } 10 is represented as 101011 in binary. The binary number { 100101 } 2 is represented as 37 in decimal. The number { 28 } 10 is represented as 1C in hexadecimal. 4. Multiple Choice: Circle the correct choice. (6 points) 4a. Ada Lovelace is widely regarded as the first: A. Computer Scientist B. Programmer C. Compiler D. Discrete Mathematician E. None of these 4b. Douglas Engelbart demonstrated the worlds first in 1964 at Stanford. A. Transistorized Computer B. Mouse C. Solid Sate Memory D. Tape Drive E. Transistor 4c. 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 the above. 2 points for each correct answer.

Page 4/6 CS 1301 Fall 2009 Exam 1 Your Name: 5. Reading Code (5 points) Act like the python interpreter and run the following program. Write what would be printed out by the program in the box to the left. def fun1(x): print "Fun1 x:", x return x * 2 print "Start" y = fun1(10) if (5 > y ): print y elif ( 15 > y ): print y + 10 elif (25 > y ): print y + 100 elif (35 > y): print y + 1000 else: print y + 10000 print "End" Start Fun1 x: 10 120 End 1 point for each line they get in the correct order, two points for getting "Fun1 x: 10" 6. Writing Code - Combinations (5 points) Write a function named combine that accepts two strings as parameters. The function should concatenate the strings (putting the second parameter after the first parameter), and return the new combined string. def combine( string1, string2): return( string1 + string2) +1 point for getting the header correct. +2 point for adding the two strings, +2 point for returning the correct result

Page 5/6 CS 1301 Fall 2009 Exam 1 Your Name: 7. Correcting Code: MovieView (6 points) Look over the following lines of code, and for each line determine if the code will run (syntax is correct). If the line of code is correct, just tell us "It works!", if it will not, please explain why/correct the error. 1: 2: 3: 4: 5: 6: define movieview(age): name = raw_input("what is your name? ") if age < 17 print "Sorry %d, you can't see the movie alone." % name else age >= 17: print "Enjoy the film, %s!" % name Line 1: def instead of define Line 2: It works! Line 3: Missing colon (:) after the 17 Line 4: %d needs to be a %s to accept a string (name) Line 5: No boolean condition after the else, remove (age >= 17) Line 6: It works! 8.Write Code - IsEven (5 points) Write a function called IsEven that accepts a single parameter anum. If anum is even (evenly divisible by 2) the function must return True, otherwise, it must return False. def IsEven( anum): if (anum % 2 == 0): return True else: return False +1 point for getting the header correct +2 points for determining if the value is even/odd +2 points for returning the correct boolean

Page 6/6 CS 1301 Fall 2009 Exam 1 Your Name: 9.Write Code - Blastoff (8 points) Write a function called blastoff that will accept a single parameter called N. Your function should start counting down from N, printing each number one per line until N reaches zero. When N reaches zero, instead of printing "0", the function should print "Blastoff!". For example, if you called blastoff and gave it an N of 5, this would be the result: >>>blastoff(5) 5 4 3 2 1 Blastoff! >>> def blastoff( N ): while (N > 0): print N N = N 1 print "Blastoff! +2 point for getting the header correct +4 points for printing each number from N to 1 (+2 if they miss one number at either end) +2 point for printing "Blastoff" at the end 10.Write Code - Count Js (10 points) Write a function named countjs that accepts a single string parameter called astring. The countj's function should keep a count of how many times the capital letter "J" appears in the string, and return the final count. def countjs( astring ): counter = 0 for letter in astring: if( letter = = "J"): counter = counter + 1 return( counter) +2 for getting the header correct +2 for having a counter that starts at zero +2 for comparing each element to a "J" +2 for incrementing the counter if it was a "J" +2 for returning a result