CMPT-166: Sample Midterm

Similar documents
CMPT-166: Sample Final Exam Answer Key

mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut

mith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1

Question 1 (10 points) Write the correct answer in each of the following: a) Write a Processing command to create a canvas of 400x300 pixels:

CISC 1600 Lecture 3.1 Introduction to Processing

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

The way I feel about music is that there is no right and wrong. Only true and false. Fiona Apple. true false false

CS110 Introduction to Computing Fall 2016 Practice Exam 1

Basic Computer Programming (Processing)

if / if else statements

Final Exam Winter 2013

1 Getting started with Processing

[ the academy_of_code] Senior Beginners

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

University of Cincinnati. P5.JS: Getting Started. p5.js

What is a variable? A named locajon in the computer s memory. A variable stores values

Name CMPS 5J Final March 17, 2010 This is a closed notes, closed book exam. Each problem is worth 1 point unless indicated otherwise.

Class #1. introduction, functions, variables, conditionals

Practice Midterm 1 Answer Key

SFPL Reference Manual

Pace University. Fundamental Concepts of CS121 1

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

CSE120 Wi18 Final Review

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

Class Notes CN19 Class PImage Page

Exam 1 - (20 points)

Practice Midterm 1. Problem Points Score TOTAL 50

Kimberly Nguyen Professor Oliehoek Introduction to Programming 8 September 2013

Conditional Events. Mouse events and Operators. Dr. Siobhán Drohan Mairead Meagher. Produced by:

CST112 Variables Page 1

CISC 1600, Lab 3.1: Processing

CISC 1600, Lab 2.1: Processing

egrapher Language Reference Manual

Interaction Design A.A. 2017/2018

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Supplementary Test 1

COS 126 Midterm 1 Written Exam Fall 2011

What can we do with Processing? Let s check. Natural Language and Dialogue Systems Lab Guest Image. Remember how colors work.

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Variables. location where in memory is the information stored type what sort of information is stored in that memory

We will start our journey into Processing with creating static images using commands available in Processing:

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

void mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position }

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

Midterm Exam CS 251, Intermediate Programming March 6, 2015

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name:

CSE373 Fall 2013, Midterm Examination October 18, 2013

CS 139 Practice Midterm Questions #2

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

INTRODUCTION TO PROCESSING. Alark Joshi, Amit Jain, Jyh-haw Yeh and Tim Andersen

CSCI 135 Programming Exam #1 Fundamentals of Computer Science I Fall 2014

CISC 1600 Lecture 2.2 Interactivity&animation in Processing

(SSOL) Simple Shape Oriented Language

Introduction to Processing. Sally Kong

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

CST112 Looping Statements Page 1

GRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation

CS 12 Fall 2003 Solutions for mid-term exam #2

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 9, Name: KEY

Using Methods. Methods that handle events. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

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

Bits and Bytes. How do computers compute?

UNIVERSITY OF WINDSOR Fall 2006 QUIZ # 1. Examiner:Ritu Chaturvedi Dated : Oct 3rd, Student Name: Student Number:

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

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

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

Computational Expression

Variables One More (but not the last) Time with feeling

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 24, Name: KEY 1

Graphics: Legacy Library

Methods (cont.) Chapter 7

PROGRAMMING FUNDAMENTALS

Functions. Functions. nofill(); point(20, 30); float angle = map(i, 0, 10, -2, 2); parameters return values

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

Exercise 1.1 Hello world

CS112 Lecture: Working with Numbers

What is a variable? a named location in the computer s memory. mousex mousey. width height. fontcolor. username

Programming with Java

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

EXAMINATIONS 2016 TRIMESTER 2

CMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, Name:

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

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:

Introduction to Processing

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

Miscellaneous Stuff That Might Be Important.

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

Variables and Control Structures. CS 110 Eric Eaton

int a; int b = 3; for (a = 0; a < 8 b < 20; a++) {a = a + b; b = b + a;}

CPSC 217 Midterm (Python 3 version)

Module 01 Processing Recap. CS 106 Winter 2018

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

Processing Assignment Write- Ups

Honors Computer Science C++ Mr. Clausen Program 6A, 6B, 6C, & 6G

A B C D CS105 03a Interaction

Full file at

Use the scantron sheet to enter the answer to questions (pages 1-6)

CSC 220 Object-Oriented Multimedia Programming, Spring 2017

Transcription:

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 1 of 11 CMPT-166: Sample Midterm Last name exactly as it appears on your student card First name exactly as it appears on your student card Student Number SFU Email Section if you know it! This is a 50 minute test. It is closed book: no calculators, computers, notes, books, etc. are allowed. True or False questions: fill in the corresponding T or F bubble for that question on your answer sheet. Multiple Choice questions: fill in the corresponding letter bubble on your answer sheet. Correct answers are worth 1 mark, and incorrect or illegible answers, or unanswered questions, are worth 0. Question Out Of True or False 50 Multiple Choice 15 Total 65

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 2 of 11 Consider the following Processing program:: size(300, 200); void draw() { rect(mousex, mousey, 10, 20); 1. When the program runs, setup() is called exactly once. 2. By default, draw() is called about 60 times per second. 3. If the setup() function was put after the draw() function, then, when the program runs, draw() would be called first, and setup() would be called second. 4. The drawing screen is 200 pixels wide. 5. There are no source code comments. 6. The program would still compile if all the ; characters were deleted. 7. 8. The program would still compile, and run the same, if all the { characters were put on their own line. The rectangle that appears on the screen leaves a trail when it moves. 9. (mousex, mousey) is the center of the rectangle that is drawn. 10 The height of the rectangle is 10 pixels.

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 3 of 11 11. Consider the following fragment of Processing code: int a = 2; a += 3; int b = 1; b += a + b; println(a b); There are exactly three different int variables defined in this code fragment. 12. There are exactly two different int literals in this code fragment. 13. The statements a += 3 adds 3 to a. 14. When run, this code fragment prints -2. 15. 16. 17. 18. 19. 20. As far as the Processing compiler is concerned, a += 3 is the same as a + = 3 (space added between the + and =). As far as the Processing compiler is concerned, a += 3 is the same as a+=3 (spaces before and after += are deleted). If the statement int b = 1 where changed to int b = 2, then this code fragment would print -3. If a += 3; was replaced by // a += 3;, then the program would not compile (i.e. there would be a compiler error). The program would still compile, and run (but may print different output), if the order of the first two statements were swapped like this: a += 3; int a = 2; println prints its output on the same window where a rectangle or ellipse would be drawn.

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 4 of 11 Consider the following Processing program: PImage mascot; size(500, 500); mascot = loadimage("duke.png"); void draw() { background(255); image(mascot, mousex, mousey); image(mascot, mousey, mousex); 21. mascot is the name of a variable of type PImage. 22. The file "duke.png" will be loaded correctly if it is in a folder named images inside the folder for this program. 23. Processing cannot display JPEG images. 24. The background color of the drawing window is black. 25. 26. The program would probably run faster if you move the line mascot = loadimage("duke.png"); out of setup() and put it into draw() (just before the calls to image). Exactly two copies of mascot are drawn on the screen, but you can only see one copy when you run the program because the images are always drawn on top of each other. 27. The center of the first image drawn is (mousex, mousey).

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 5 of 11 Consider the following fragment of Processing code: int x = 3; // initial value of x int y = 3; // initial value of y if (x <= y) { println("hello!"); else { println("goodbye!"); 28. It prints hello! when run. 29. 30. 31. If <= were replaced by >=, the program would print goodbye! when run. If <= were replaced by!=, the program would print goodbye! when run. If <= were replaced by <, the program would print goodbye! when run. 32. If <= were replaced by >, the program would print hello! when run. 33. If <= were replaced by ==, the program would print hello! when run. 34. If <= were replaced by =, the program would print hello! when run. 35. 36. 37. If x <= y were replaced by x + 1 <= y 2, the program would print goodbye! when run. If x <= y were replaced by x == x, the program would print hello! when run, even if you changed the initial values of x and y to be randomly chosen ints. If the two { characters and the two characters were deleted, then the code would still compile, and run the same way.

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 6 of 11 For each of the following boolean expressions, choose T if it evalautes to true, and F otherwise. 38. true false 39. true true 40. false && false 41. false false true false 42.!(true false) 43. (!false) && true 44.!!!true 45.!(!false &&!false) 46.!(!false!false) 47.!(true &&!!(false false)) 48. 49. If a and b are both variables of type int, and a > 0 and b > 0, then it is always the case that a + b > 0. If a is a variable of type int, and a < 0, then it is always the case that abs(a) > 0 (abs calculates the absolute value of a). 50. If a is a variable of type int, then a a is always 0.

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 7 of 11 Multiple Choice 51. Processing is an example of: a) a scripting language b) an assembly language c) a low-level language d) a high-level language 52. Which one of the following tokens marks the beginning of a code block in Processing? a) { b) ( c) // d) ) 53. Which of the following is a major difference between Processing's default screen coordinates and the coordinates used in mathematics? a) the x and y values of a coordinate are swapped, e.g. in math you would write (3, 2), but in Processing you would write it (2, 3) b) the x-axis increases to the left (instead of to the right) c) the y-axis increases down (instead of up) d) there is no difference 54. Processing's quad function is used to draw shapes with 4 edges, such as squares, rectangles, and bow-ties. How many different input numbers does quad require? a) 4 b) 8 c) 12 d) 16

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 8 of 11 55. Approximately how many distinct colors can Processing's RGB color notation represent? a) 16.7 thousand b) 16.7 million c) 16.7 billion d) 16.7 trillion 56. What number should replace? to make this statement print 5.0? println(map(?, 0, 20, 0, 10)); a) 0 b) 5 c) 10 d) 20 57. What does CPU stand for? a) computer power unit b) computer processing unit c) central power unit d) central processing unit 58. How many different levels of transparency does Processing's RGB color support? a) 0 b) 2 c) 256 d) about 16 million 59. What does this print? print(min(max(3, 2), min(4, 7))); a) 2 b) 3 c) 4 d) 7

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 9 of 11 60. Which one of these statements is false? a) folders can contain folders or files (and maybe other things, like shortcuts) b) a folder cannot contain 2 (or more) things with the same name (except for one special case!) c) in Processing, absolute path names are almost always better and more useful than relative path names d) folder and directory mean the same thing 61. What does this print? int n; println(n); a) nothing: it causes a compile-time error b) nothing: it causes a run-time error c) 0 d) some unknown integer value 62. What does this print? println(n); int n; a) nothing: it causes a compile-time error b) nothing: it causes a run-time error c) 0 d) some unknown integer value

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 10 of 11 63. What does this print? float x = int(3.0); println(x); a) nothing: it causes a compile-time error b) nothing: it causes a run-time error c) 3 d) 3.0 64. In Processing, an int is represented by 32 bits. What is the maximum positive number that a Processing int can represent? a) 2 31-1 b) 2 31 c) 2 32-1 d) 2 32 65. Which one of the following is a string literal in Processing? a) apple b) 'apple' c) "apple" d) none of the above

CMPT 166, Fall 2016, Surrey Sample Midterm 1 Page 11 of 11