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

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

CMPSCI 119 Fall 2017 Monday, October 10, 2017 Midterm #1 Solution Key Professor William T. Verts

CMPSCI 119 Spring 2014 Friday, November 7, 2014 Midterm #2 Solution Key Professor William T. Verts

CMPSCI 119 Spring 2017 Wednesday, March 29, 2017 Midterm #2 Professor William T. Verts QUESTION POINTS SCORE TOTAL 100

CMPSCI 119 LAB #2 Anime Eyes Professor William T. Verts

CMPSCI 119 Spring 2015 Wednesday, April 1, 2015 Midterm #2 Solution Key Professor William T. Verts

CMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts

CMPSCI 119 Spring 2015 Final Exam Friday, May 1, 2015 Solution Key

CMPSCI 119 LAB #3 Fish Tank Professor William T. Verts

CMPSCI 119 LAB #4 Fish Tank Professor William T. Verts

CMPSCI 120 Extra Credit #1 Professor William T. Verts

Review Sheet for Midterm #1 COMPSCI 119 Professor William T. Verts

CMPSCI 120 Fall 2015 Midterm Exam #2 Solution Key Monday, November 16, 2015 Professor William T. Verts

NAME: Question Points TOTAL 100

CISC 1600, Lab 2.1: Processing

Easy Graphical User Interfaces

CMPSCI 120 Fall 2016 Professor William T. Verts

1. Complete these exercises to practice creating user functions in small sketches.

CISC 1600, Lab 3.1: Processing

Overview of List Syntax

CS110 Introduction to Computing Fall 2006 Midterm Exam

CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015

CS 184, Fall 1996 Midterm #1 Professor: unknown

1. (10 pts) Order the following three images by how much memory they occupy:

CSC 110 Final Exam. ID checked

Solution Notes. COMP 151: Terms Test

CSE 131 Introduction to Computer Science Fall Exam II

Processing Assignment Write- Ups

CS 184, Fall 1996 Midterm #1 Professor: unknown

Recipes4Success. Draw and Animate a Rocket Ship. Frames 5 - Drawing Tools

easel Manager Danielle Crosswell dac2182 Language Guru Tyrus Cukavac thc2125 System Architect Yuan-Chao Chou yc3211 Tester Xiaofei Chen xc2364

Image Size vs. File Size. gif File Compression. 1 Review. Slides05 - Pixels.key - September 28, 2015

Written test, 25 problems / 90 minutes

CS 1110 Prelim 1 March 10, 2015

Chapter - 2: Geometry and Line Generations

The while Loop 4/6/16 4

CPSC 217 Midterm (Python 3 version)

Skills Quiz - Python Edition Solutions

CSci 1113, Fall 2015 Lab Exercise 11 (Week 13): Discrete Event Simulation. Warm-up. Stretch

CS 101 Computer Science I Fall Instructor Muller. stddraw API. (DRAFT of 1/15/2013)

COS 126 Midterm 1 Written Exam Fall 2011

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM

Midterm I Practice Problems

CISC 1600 Lecture 3.1 Introduction to Processing

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

MIDTERM 3 PART 1 (CHAPTER 4) INTRODUCTION TO TRIGONOMETRY; MATH 141 FALL 2018 KUNIYUKI 150 POINTS TOTAL: 30 FOR PART 1, AND 120 FOR PART

Review 4. Lists and Sequences

CS 1301 Exam 1 Fall 2014

CSc 110, Spring 2018 Lecture 9: Parameters, Graphics and Random. Adapted from slides by Marty Stepp and Stuart Reges

COMPSCI 119 Extra Credit Lab #2 Bar Codes Professor William T. Verts

Midterm #1 Fall minutes

Here is a sample IDLE window illustrating the use of these two functions:

Art, Nature, and Patterns Introduction

CMPSCI 105 Midterm Exam Solution Spring 2008 March 27, 2008 Professor William T. Verts

Scalable Vector Graphics (SVG) vector image World Wide Web Consortium (W3C) defined with XML searched indexed scripted compressed Mozilla Firefox

Draw beautiful and intricate patterns with Python Turtle, while learning how to code with Python.

Graphical User Interfaces

CSc 110, Autumn 2016 Lecture 7: Graphics. Adapted from slides by Marty Stepp and Stuart Reges

Ū P O K O O T E I K A A M Ā U I U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2014 TRIMESTER 1 *** WITH SOLUTIONS ***

Intro. Scheme Basics. scm> 5 5. scm>

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

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

Structured Programming Using C++ Lecture 10 : Graphics Programming with the Dark GDK Library. Dr. Amal Khalifa. Lecture Contents:

CS 1301 Exam 2 Fall 2013

Garfield AP CS. Graphics

Midterm #1a Fall minutes

Put your initials on the top of every page, in case the pages become separated.

User Interfaces. getting arguments of the command line a command line interface to store points fitting points with polyfit of numpy

CS 1301 Exam 1 Fall 2013

Getting Started with Python

CAS London CPD Day February 16

Midterm Exam CS 184: Foundations of Computer Graphics page 1 of 11

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

egrapher Language Reference Manual

Building Java Programs

EXAMINATIONS 2017 TRIMESTER 2

CMPSCI 145 MIDTERM #2 Solution Key SPRING 2018 April 13, 2018 Professor William T. Verts

2.6 Graphics SIMPLE DRAWINGS 9/9/16 74

It is useful for the user of this software to keep in mind the following points:

CSCI 111 First Midterm Exam Fall Solutions 09.00am 09.50am, Wednesday, October 18, 2017

CS 1301 Exam 1 Fall 2010

CS 111: Digital Image Processing Fall 2016 Midterm Exam: Nov 23, Pledge: I neither received nor gave any help from or to anyone in this exam.

Homework 5: Graphics Due: 11:59pm on Thursday, October 22

Warping & Blending AP

Performance Assessment Spring 2001

CMPSCI 105 Midterm Exam Solution Spring 2005 March 24, 2005 Professor William T. Verts

Preparation: Get to know the Java coordinate system. 3. How is the background color of the window specified? Copy the exact code:

CMPSCI 105 Midterm Exam Solution Spring 2004 March 25, 2004 Professor William T. Verts

Java - Applets. public class Buttons extends Applet implements ActionListener

CMPSCI 120 Fall 2017 Midterm Exam #1 Solution Key Friday, October 6, 2017 Professor William T. Verts

Types, lists & functions

61A Lecture 3. Friday, September 5

Programming Project 1

Media Computation Module

[ the academy_of_code] Senior Beginners

Mirage. Language Reference Manual. Image drawn using Mirage 1.1. Columbia University COMS W4115 Programming Languages and Translators Fall 2006

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto

Nets and Drawings for Visualizing Geometry. Unit 1 Lesson 1

CMPSCI 119 LAB #1 Bar Graphs Professor William T. Verts

Honors Computer Science Python Mr. Clausen Program 7A, 7B

Transcription:

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

<1> 25 Points What is the value of each expression below? Answer any 25; answer more for extra credit. Answer Error if an expression cannot be computed for any reason. Scoring: +1: Completely correct answers +½: Incorrect data types, lists without square brackets, strings without quotes, etc. 0: Blank answers ½: Incorrect answers (better to leave it blank than to guess) X15 = 7 ME262 = 10L F104 = "PLANES AND SPACE" B17 = ["AIR", 7, "TRAINS", 8.5, 3] XF85 = ("SPACECRAFT", [4, 1, 3], 5L, 6.2) 1. 3 int X15 / 2 2. 17 int X15 + ME262 3. 16.2 float ME262 + XF85[-1] 4. 16 int len(f104) 5. 3 int len(b17[0]) 6. ERROR len(me262) 7. 3 int len(xf85[1]) 8. 15L (or ERROR) long ME262 + XF65[2] (should be XF85[2]) 9. ERROR B17 + XF85 10. 8.0 float X15 + 1.0 11. [4,1,3,7] list XF85[1] + [X15] 12. "AIRPLANES AND SPACE" B17[0] + F104 13. [0,1,2,3,4,5,6] range(x15) 14. [3,4,5,6] range(b17[-1],x15) 15. [1,8,15,22] range(1,25,x15) 16. ERROR range(f104) 17. ERROR XF85[0] + ME262 18. 9 int len(b17[0]+b17[2]) 19. 1 int X15 % 2 20. False bool X15 < 3 21. 5 int 5 * (X15 > 4) 22. 49.0 float X15**2.0 23. [4,1,3,0,1,2] XF85[1] + [I for I in range(3)] 24. [-7,0,7] range(-x15,x15+1,x15) 25. 8.5 float B17[B17[-1]] 26. [0,0,0,0,0,0,0] [0 for I in range(x15)] 27. [10,15,9] [X15 + I for I in [3,8,2]] 28. ["A","I","R"] [CH for CH in B17[0]] 29. [1,1,1] [len(ch) for CH in B17[0]] 30. ["R","I","A"] [B17[0][len(B17[0])-1-I] for I in range(len(b17[0]))] Page 1

<2> 20 Points (2 points each answer) When Main() is called there will be exactly ten lines of output printed. What are they? def FN1 (F,R,O,G=1): # Answer #1 4 global Newt # Newt = (F * R) + (O * G) # Answer #2 18 print Newt + F # # Answer #3 14 # def FN2 (T,O,A,D): # Answer #4 3 global Newt # FN1 (D+Newt,O,A,T) # Answer #5 7 print Newt # # Answer #6 4 # def Main(): # Answer #7 11 FN1 (1,2,1) # FN2 (3,2,2,1) # Answer #8 6 FN1 (1,1,1,1) # FN2 (1,1,1,1) # Answer #9 28 FN2 (1,1,1,1) # FN2 (2,2,2,2) # Answer #10 20 # <3> 10 Points I have a program that scans every pixel in an image, and calls function Process with each pixel in variable PX. Complete the Process function to transform the pixel by converting it to black if the brightness is less than 50, white if the brightness is greater than 200, and gray otherwise. (The only JES functions you need are getred, getgreen, getblue, and setcolor., but no canvases or loops are needed.) def Process(PX): Brightness = (getred(px)+getgreen(px)+getblue(px))/3 if (Brightness > 200): setcolor(px,white) elif (Brightness < 50): setcolor(px,black) else: setcolor(px,gray) Scoring: 2 points for computing the brightness, 3 points for the if-elif-else structure (can be if-if-if), 1 point each for the three setcolor calls, 2 points for syntax errors. Page 2

<4> 25 Points Each grid square in the gray alignment grid is 10 pixels on a side. A Widget, centered at location <X,Y> (shown with a dot), is a red circle of radius 100 pixels, with four Corner shapes on top. Each Corner is centered 80 pixels in both X and Y away from the Widget center. A Corner is, relative to its own <X,Y>, a centered yellow square of side-radius 50, with four green circles of radius 20 on top of it, 25 pixels in both X and Y away from its center, a blue square of side-radius 30 on centered top of the circles, and a yellow circle of radius 20 centered on top of all. Fill in the blanks below to complete the drawing of a Widget. The Circle and Square functions are already provided. def Circle (Canvas, Xc, Yc, Radius, NewColor=black): def Square (Canvas, Xc, Yc, Radius, NewColor=black): def Widget (Canvas, X, Y): def Corner (X, Y): Square(Canvas, _X, _Y, 50, yellow) Circle(Canvas, _X-25_, _Y-25_, 20, green ) Circle(Canvas, _X+25_, _Y-25_, 20, green ) Circle(Canvas, _X-25_, _Y+25_, 20, green ) Circle(Canvas, _X+25_, _Y+25_, 20, green ) Square(Canvas, _X, _Y, 30, blue ) Circle(Canvas, _X, _Y, 20, yellow) Circle (Canvas, _X_, _Y_, _100_, _red_) for Row in [-1,1]: for Column in [-1,1]: Corner (_X + 80 * Column_, _Y + 80 * Row_) Scoring: There are 34 slots to be filled in; 24 have either a single variable (X or Y), a number, or a color: score those as ½ point each for 12 points. There are 8 that are ±25: score those as 1 point each for 8 points. The last two slots are complicated: score those as 2 points each for 4 points. Give 1 point free for any non-blank answers. NOTE: the four sequential Circle commands can be in any order. Page 3

<5> 5 Points Refer to the BlendPoints function we developed in class (or see the bottom of page 298 of the Companion). What is ed by the following function call? BlendPoints ([4,12,8], [20,24,40], 0.25) [8.0, 15.0, 16.0] Scoring: 1 point for each of the three values, 1 point for the list [] brackets, and 1 point for other syntax problems. <6> 5 Points Show on the orthographic axes below where the point <-6,5,3> is located. Refer to page 320 in the Companion for how the answer should be drawn. <7> 10 Points Write a complete Python function called Guess, with no parameters, that use the python input function to ask the user for a numeric input between 0 and 100 (inclusive). It continues to do so if the user enters anything outside that range, but then s the entered value when it is inside the correct range. def Guess(): N = input("enter a number in [0...100]") while (N < 0) or (N > 100): N = input("enter a number in [0...100]") N Scoring: 2 points for def Guess():, 2 points for the first input statement, 3 points for the while loop, 2 points for the second input statement, and 1 point for the. Page 4