CS110 Introduction to Computing Fall 2006 Midterm Exam

Similar documents
All program statements you write should be syntactically correct. Partial credit is not guaranteed with incorrect use of syntax.

CS110 Introduction to Computing Fall 2016 Practice Exam 1 -- Solutions

CS110 Introduction to Computing Fall 2016 Practice Exam 1

CS 455 Midterm Exam 1 Spring 2015 [Bono] Thursday, Feb. 19, 2015

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

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

CS 115 Exam 1, Fall 2015 Thu. 09/24/2015

Midterm #1a Fall minutes

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

CSC 110 Final Exam. ID checked

Spring Semester 13, Dr. Punch. Exam #1 (2/14), form 1 A

CMPSCI 119 Fall 2018 Wednesday, November 14, 2018 Midterm #2 Solution Key Professor William T. Verts

COS 126 Midterm 1 Written Exam Fall 2011

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, October 13, 2015

***PRACTICE EXAM 02 for*** CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Actual exam scheduled for: 11/18/2009

Fall 08, Sherri Goings, Exam #1 (10/2), form 1 B

Fundamentals of Programming (Python) Getting Started with Programming

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

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

CITS 4406 Problem Solving & Programming. Lecture 03 Numeric Data Processing

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Instructor: Final Exam Fall Section No.

Getting Started with Python

EXAMINATION INSTRUCTIONS

Structure and Interpretation of Computer Programs

cs1114 REVIEW of details test closed laptop period

Spring Semester 08, Dr. Punch. Exam #1 (2/12), form 1 B

CS 111X - Fall Test 1

Spring CS Homework 3 p. 1. CS Homework 3

Practice midterm exam

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

CSCE 110 Programming I Basics of Python: Lists, Tuples, and Functions

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016

Spring Semester 08, Dr. Punch. Exam #1 (2/12), form 1 A

CS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, Good Luck!

Practice Midterm 1. Problem Points Score TOTAL 50

Comp 151. Using Objects (and the beginning of graphics)

CPSC 217 L01 Midterm

1 Fall 2017 CS 1110/1111 Exam 3

Variable and Data Type I

EXAMINATION INSTRUCTIONS

CMPSCI 119 Fall 2018 Thursday, November 29, 2018 Midterm #3 Solution Key Professor William T. Verts

ECS 15: Introduction to Computers Finals March 19, 2010

CPSC 217 Midterm (Python 3 version)

Structure and Interpretation of Computer Programs

CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011

University of Washington CSE 140 Introduction to Data Programming Winter Midterm exam. February 6, 2013

Introduction to Computer Science Midterm 3 Fall, Points

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Computer Science 217

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

Variable and Data Type I

NOTE: All references to Python on this exam mean Python 3, so you should answer accordingly.

CS 1301 Exam 1 Fall 2009

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

Expressions, Statements, Variables, Assignments, Types

Structure and Interpretation of Computer Programs

CSE 123: Computer Networks Fall Quarter, 2017 MIDTERM EXAM

COS 226 Fall 2015 Midterm Exam pts.; 60 minutes; 8 Qs; 15 pgs :00 p.m. Name:

CSE 131 Introduction to Computer Science Fall Exam I

Name: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015

Practice Midterm 1 Answer Key

Structure and Interpretation of Computer Programs Fall 2016 Midterm 2

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

CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012

Chapter 5 Conditional and Iterative Statements. Statement are the instructions given to the computer to perform any kind of action.

University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CSC 108H1 F 2009 Test 1 Duration 35 minutes Aids allowed: none. Student Number:

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

Structure and Interpretation of Computer Programs Fall 2015 Midterm 2

CPSC 217 Midterm (Python 3 version)

CSC201, SECTION 002, Fall 2000: Homework Assignment #2

CS 455 Midterm Exam 1 Fall 2013 [Bono] Wednesday, Oct. 2, 2013

Lecture 7: Functions. CS1068+ Introductory Programming in Python. Dr Kieran T. Herley 2018/19. Department of Computer Science University College Cork

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

Comp 150 Exam 2 Overview.

University of Washington CSE 140 Introduction to Data Programming Winter Midterm exam. February 6, 2013

Exam 2. Name: UVa ID:

Structure and Interpretation of Computer Programs Fall 2015 Midterm 1

CS177 Recitation. Graphics. Python Programming, 2/e 1

CS 320 Midterm Exam Solution

CS1800 Discrete Structures Fall 2017 October 25, CS1800 Discrete Structures Midterm Version B

CS 1301 Exam 1 Answers Fall 2009

University of Illinois at Chicago Department of Computer Science. Final Examination. CS 151 Mathematical Foundations of Computer Science Fall 2012

Programming revision. Revision tip: Focus on the things you find difficult first.

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

Exam #1, Form 1 A CSE 231 Spring 2015 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

Introduction to: Computers & Programming: Review prior to 1 st Midterm

Structure and Interpretation of Computer Programs

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

THE AUSTRALIAN NATIONAL UNIVERSITY Mid Semester Examination September COMP1730 / COMP6730 Programming for Scientists

Select the ONE best answer to the question from the choices provided.

Computer Science 1 CSCI-1100 Spring Semester 2015 Exam 1 Overview and Practice Questions

Macroanalysis. futureoftech/data-mining-classics-makesbeautiful-science

Exam 1, Form A CSE 231 Fall 2012 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function

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

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

Python 2 Conditionals and loops Matthew Egbert CS111

Transcription:

CS110 Introduction to Computing Fall 2006 Midterm Exam Name: This is an open book/notes exam. Sharing of notes and books is not permitted. Answer all questions in the space provided. Continue on back of page if needed. This exam contains 8 questions, pages numbered 1-8. This exam is designed to be taken in 80 minutes. Assume that any given Python statements do not have typographical errors. All Python statements you write should be syntactically correct. There will be no credit for incorrect use of Python syntax. Please remember to sign the attendance sheet. Good Luck! Question # Points Maximum Points 1. 10 2. 10 3. 10 4. 10 5. 10 6. 10 7. 10 8. 10 Total 80 1

Question 1 (10 points) Circle the correct answer in each of the following: 1. Which of the following is not one of the functional building blocks of a computer system: 1. central processing unit 2. main memory 3. secondary memory 4. monitor 2. A step-by-step set of instructions for accomplishing some task is called 1. a calculation 2. an expert system 3. an interpreter 4. an algorithm 3. What would Python print as a result of this interaction: >>> print 2 + 3 1. 2+3 2. 2+3 = 5 3. Error 4. 5 4. What is the effect of the Python statement: for i in range(10): 1. It multiplies i times 10. 2. It looks for the value of i in the number 10. 3. It causes the program to do something 10 times. 4. Nothing, this is just a comment. 5. Which of the following is a correct Python expression for converting temperatures from Celsius to Fahrenheit? 1. fahrenheit = (9.0/5.0)celsius + 32 2. fahrenheit = (9.0/5.0) * celsius + 32 3. fahrenheit = (9.0/5.0) (celsius + 32) 4. fahrenheit = (9.0/5.0) * (celsius +32) 2

6. What is printed by the following Python fragment? s = "Bryn Mawr College" print s[1] 1. B 2. Bryn 3. e 4. r 7. Suppose that the variable x currently has the value 20. What statement would cause the value of x to become 25? 1. x + 5 2. y = x + 5 3. x = x + 5 4. None. The value of x can't be changed. 8. What is printed by the following Python fragment? s = "Bryn Mawr College" print s[-1] 1. B 2. Bryn 3. e 4. College 9. What is the result of evaluating 7/2? 1. 1 2. 2 3. 3 4. 5 10. What is the result of evaluating 7%2? 1. 1 2. 2 3. 3 4. 5 3

Question 2 (5 points) This question concerns strings in Python. Assume that the string module has been imported. Given the following: str = Baa, baa black sheep str2 = baa Give the output of each of the following expressions: a) str[5] b b) str[3:9], baa c) str[:5] Baa, d) str[:] Baa, baa black sheep e) str[-2] e f) string.count(str, a ) 5 g) string.find(str, str2) 5 h) str2 + - + str 'baa-baa, baa black sheep' i) len(string.split(str)) 4 j) (string.capitalize(str2) +, )*3 'Baa,Baa,Baa,' Question 3 (10 points) Consider the following program: num = input("enter a number: ") for i in range(5): num = num / 2 print num main() Suppose the input to this program is 1024, what is the output? 32 4

Question 4 (10 points) The following Python program is supposed to draw a blue circle of diameter 100 pixels in the center of the window. Write the appropriate commands needed to accomplish the task. from graphics import * # open the graphics window win = GraphWin( My Graphics Window, 600, 400) # Draw a blue circle of diameter 100 in the center center = Point(300, 200) # or Point(299, 199) radius = 50 circ = Circle(center, radius) circ.setfill( red ) circ.draw(win) # end of program main() 5

Question 5 (10 points) What is the output from the following program fragment? for i in [1,3,5,7]: print 2 * i, 2 6 10 14 Question 6 (10 points) What is the output from the following program fragment? n = 5 for i in range(n): print i, :, i*i 0 : 0 1 : 1 2 : 4 3 : 9 4 : 16 6

Question 7 (10 points) Write a Python program that opens a file and prints out its first and last lines. Your program should ask the user for the file name. fname = raw_input( Please enter a file name: ) file = open(fname, r ) lines = file.readlines() print lines[0], print lines[-1], 7

Question 8 (10 points) Answer one of the following (circle the one you choose): 1) Write a Python program to sum the ASCII codes for all characters in an input string. For example, for the string, ABC, the output will be 198 (because the character codes for A, B, and C are 65, 66, and 67, respectively and 65+66+67=198) import string sum = 0 str = raw_input( Enter a string: ) for i in str: sum = sum + ord(i) print The sum of ASCII codes is, sum 2) Write a Python program that computes and prints out the average of all the integers between any two given integers (inclusive). Here are two examples: If the numbers input are 1 and 5, the result will be 3.0 (since 1+2+3+4+5 = 15 divided by 5 = 3.0). If the numbers input are -1 and 2, the result will be 0.5 (since -1+0+1+2 = 2, divided by 4 = 0.5) You may assume that the second input number is always bigger than the first. x, y = input( Please enter two integers: ) # n to count the number of integers # can also be calculated directly as y-x+1 sum, n = 0, 0 for i in range(x, y+1): sum = sum + i n = n+1 avg = sum/float(n) print The average is, avg 8