Spring 2017 CS 1110/1111 Exam 1

Similar documents
Spring 2017 CS 1110/1111 Exam 2

(the bubble footer is automatically inserted into this space)

Spring 2017 CS 1110/1111 Exam 3

1 Fall 2017 CS 1110/1111 Exam 3

CS 111X - Fall Test 1

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

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

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

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

Short Answer Questions (40 points)

CSSE 120 Introduction to Software Development Practice for Test 1 paper-and-pencil part Page 1 of 6

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

CS3330 Exam 1 Spring Name: CS3330 Spring 2015 Exam 1 Page 1 of 6 ID: KEY

CSCI 150 Exam 2 Solutions

(the bubble footer is automatically inserted into this space)

CSE 247 Data Structures and Algorithms Fall Exam I

CSE 131 Introduction to Computer Science Fall Exam I

CSE 131 Introduction to Computer Science Fall Exam II

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

CS 2316 Exam 1 Spring 2013

CS 141, Lecture 3. Please login to the Math/Programming profile, and look for IDLE (3.4 or the unnumbered. <-- fine <-- fine <-- broken

CS Name : Grading TA:

CSE 131 Introduction to Computer Science Fall Exam I

CS143 Final Spring 2016

CS 3330 Final Exam Spring 2016 Computing ID:

Prelim 2. CS 2110, 16 November 2017, 7:30 PM Total Question Name Short Heaps Tree Collections Sorting Graph

Structure and Interpretation of Computer Programs Spring 2017 Mock Midterm 1

Prelim 2 SOLUTION. CS 2110, 16 November 2017, 7:30 PM Total Question Name Short Heaps Tree Collections Sorting Graph

CS 1301 Exam 1 Spring 2014

First name (printed): a. DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

Spring Semester 10 Exam #1 Dr. Dillon. (02/18)

CS 1301 Exam 1 Fall 2010

Structure and Interpretation of Computer Programs

CS 3330 Exam 2 Spring 2016 Name: EXAM KEY Computing ID: KEY

CS3330 Spring 2015 Exam 2 Page 1 of 6 ID:

Structure and Interpretation of Computer Programs

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

(the bubble footer is automatically inserted into this space)

CS 1301 Exam 1 Spring 2014

CSE 131 Introduction to Computer Science Fall Final Exam

CS 1803 Fall 2010 Exam 1

(the bubble footer is automatically inserted in this space)

Lesson 13: Exploring Factored Form

(the bubble footer is automatically inserted into this space)

CS 1301 Exam 1 Fall 2010

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016

Decision Logic: if, if else, switch, Boolean conditions and variables

Final Exam COMP Fall 2004 Dec 16, 2004

CS 1803 Fall 2010 Exam 1

CS 2316 Exam 1 Spring 2014

Structure and Interpretation of Computer Programs

7. (2 pts) str( str( b ) ) str '4' will not compile (single, double, or triple quotes

Structure and Interpretation of Computer Programs

Name: Partner: Python Activity 9: Looping Structures: FOR Loops

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

CS3330 Fall 2014 Exam 2 Page 1 of 6 ID:

CS 1301 Exam 1 Fall 2009

CS 3330 Exam 2 Fall 2017 Computing ID:

CSE 131S Introduction to Computer Science Summer SON Exam I

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

CS143 Midterm Spring 2014

CPSC 217 Midterm (Python 3 version)

CS 115 Lecture 4. More Python; testing software. Neil Moore

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.

This is a combination of a programming assignment and ungraded exercises

Version B Final Exam

This exam is worth 24 points, or 24% of your total course grade. The exam contains six

CS 1301 Exam 1 Spring 2011

Spring Semester 11 Exam #1 Dr. Dillon. (02/15)

CS 415 Midterm Exam Spring 2002

Programming Assignment - 1

CS 111X - Spring Final Exam - KEY

Properties and Definitions

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.

Do not start the test until instructed to do so!

Final Exam. COMP Summer I June 26, points

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

CSE 160 Winter 2016: Final Exam

CS100 Spring 2017 Final

: Intro Programming for Scientists and Engineers Final Exam

CSCE 110: Programming I

(the bubble footer is automatically inserted in this space)

Midterm Exam 2B Answer key

CS 1301 Exam 1 Fall 2013

def F a c t o r i a l ( n ) : i f n == 1 : return 1 else : return n F a c t o r i a l ( n 1) def main ( ) : print ( F a c t o r i a l ( 4 ) )

Common Loop Algorithms 9/21/16 42

COS 126 General Computer Science Spring Written Exam 1

CS 1301 Exam 1 Answers Fall 2009

Spring Semester 09 Exam #1 Dr. Dillon. (02/19)

CS145 Midterm Examination

CS 1301 Exam 1 Fall 2013

Structure and Interpretation of Computer Programs Spring 2019 Midterm 2

COS 226 Midterm Exam, Spring 2009

CS3330 Exam 3 Spring 2015

CS150 Sample Final. Name: Section: A / B

CSE 131 Introduction to Computer Science Fall Exam I

Reviewing all Topics this term

(the bubble footer is automatically inserted in this space)

CS 1301 Exam 1 Fall 2014

Computer Science 217

Transcription:

CS 1110/1111 Spring 2017 Exam 1 page 1 of 6 Spring 2017 CS 1110/1111 Exam 1 Bubble in your computing ID in the footer of this page. We use an optical scanner to read it, so fill in the bubbles darkly. If you have a shorter ID, leave some rows blank. In case we have trouble with the scanner, please also legibly print Your name: Your computing ID: Please observe the following directions throughout the exam: Write legibly; we deduct points if we are unsure what you wrote. Indentation and punctuation do matter. Write on the lines, where possible. If you need to insert a line between two you ve written, make it clear that that is what you are doing. We grade one page at a time. Do not spill answers onto another page. Don t add features we didn t request: only print if we ask you to print, etc. The exam is being given in multiple locations simultaneously, so we cannot fairly answer student questions during the exam. If you find a question ambiguous or unclear, write that down on your exam and we ll give it due consideration during grading. Pledge On my honor as a student, I have neither given nor received help or assistance on this exam. Signed:

CS 1110/1111 Spring 2017 Exam 1 page 2 of 6 Question 1 (14 points) Fill in the following table. The first row is done for you. If the expression results in an error, write ERROR on that row. Expression Value Type 3 + 4.0 7.0 float 3 / 6 6 // 2 4 % 2 "1" + "3" 1 + 3 int("2.5") str(1+2) Question 2 (7 points) Circle either OK or Error on each row to identify if each code snippet would generate an error or not. Assume that x is a variable that is re-set to contain the value 11 before each row. Code OK Error 3 = x OK Error x = 3 OK Error n = input "Your name: " OK Error "x = " + x OK Error int(str(float(x))) OK Error "4" * 3 OK Error "4" ** 3

CS 1110/1111 Spring 2017 Exam 1 page 3 of 6 Question 3 (12 points) Each of the following two programs output three lines of text. Write that output in the blanks provided. def f(): global word word = "happy" def f(word): word = "happy" word = "gleeful" f() word = "gleeful" f(word) Question 4 (2 points) What is the difference between print and return? Question 5 (12 points) Assume we run the following Python program. In the comment next to each print, write what the code prints when the corresponding line is run. def baz(x): print('x =', x) # prints x = x = x - 2 print('x =', x) # prints x = return x x = 10 print('x = ', x) # prints x = x = x - 2 print('x = ', x) # prints x = y = baz(x) print('x = ', x) # prints x = print('y = ', y) # prints y =

CS 1110/1111 Spring 2017 Exam 1 page 4 of 6 Question 6 (10 points) Write a function named repeat that takes a single positive integer argument; the function prints its argument a number of times equal to its argument s value, all on one line, separated by spaces. For example, repeat(3) should print 3 3 3 ; repeat(5) should print 5 5 5 5 5 ; etc. Question 7 (15 points) If a piece of text is made up of random lower-case English letters and numerals, the total number of possible pieces of text n letters long is 36 n. Write a Python function named options that, given a single str parameter, returns the number of strings of that length that can be constructed from lower-case English letters and numerals. For example, options('hi') should return 1296 (which is 36 2 )

CS 1110/1111 Spring 2017 Exam 1 page 5 of 6 Question 8 (24 points) Write a program that asks the user to type two integers. If either integer is evenly divisible by the other, print (number) is divisible by (number) ; otherwise print (number) and (number) are not divisible by one another. For example, one run might be Enter an integer: 12 Enter another integer: 3 12 is divisible by 3 Another run might be Enter an integer: 12 Enter another integer: 30 12 and 30 are not divisible by one another

CS 1110/1111 Spring 2017 Exam 1 page 6 of 6 Question 9 (4 points) Consider the problem of ordering a list of numbers, from smallest to largest. Two algorithms are given below: 1. Search through the input list once from beginning to end. Examine each pair of adjacent elements. If these are out of order, swap them. 2. Create an empty output list. Find the smallest element in the input list. Remove that element from the input list and add it to the end of the output list. Repeat those two steps until the input list is empty. Which of the algorithms above produce an ordered list (from smallest to largest)? Circle the appropriate letter. A. Just algorithm (1) B. Just algorithm (2) C. Both algorithms D. Neither algorithm