Final Exam, Version 2 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Similar documents
Final Exam, Version 1 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 3 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Sample Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 2 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 4 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 1 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Final Exam, Version 3 CSci 127: Introduction to Computer Science Hunter College, City University of New York

Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

The American University in Cairo Computer Science & Engineering Department CSCE Dr. KHALIL Exam II Spring 2010

The American University in Cairo Department of Computer Science & Engineeringt CSCI &09 Dr. KHALIL Exam-I Fall 2009

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science. Instructor: Final Exam Fall 2011

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Dr. Khalil Exam II Fall 2011

CSci 127: Introduction to Computer Science

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey

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

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

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

CSci 127: Introduction to Computer Science

In this chapter you will learn:

LAB 4.1 Relational Operators and the if Statement

Control Flow: Loop Statements

Do not turn to the next page until the start of the exam.

CSci 127: Introduction to Computer Science

University of Michigan EECS 183: Elem. Programming Concepts Fall 2011 Exam 1: Part 1: Form 1. Professors: ML Dorf, Elliot Soloway

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS240 BRANCHING STATEMENTS

Final Examination Semester 2 / Year 2005

Read this before starting!

CSCE Practice Midterm. Data Types

CSci 127: Introduction to Computer Science

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

CPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

Exam 2. CSI 201: Computer Science 1 Fall 2016 Professors: Shaun Ramsey and Kyle Wilson. Question Points Score Total: 80

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators

Introduction to Programming I COS1511 School of Computing Revision Notes

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Tutorial Letter 103/1/2017 Introduction to Programming I

CS150 Sample Final. Name: Section: A / B

CSCE Practice Midterm. Data Types

REPETITION CONTROL STRUCTURE LOGO

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

EECS 183 Fall 2015 Exam 2 Free Response (134 points)

Computer Science Grade 10 Sample -Term 2 Date: February 2018 Time: TBC Duration: 45 minutes

Lecture 23: Pointer Arithmetic

Lecture 1. Course Overview, Python Basics

Read this before starting!

Lecture #9 **go to Blackboard ** Review from Shackelford Reading If statements Loops. Using if statements and loops

Jordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A

C++ Programming: From Problem Analysis to Program Design, Third Edition

Section 001. Read this before starting!

CSc Introduc/on to Compu/ng. Lecture 8 Edgardo Molina Fall 2011 City College of New York

1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?

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

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

Python: common syntax

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3

4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme

Read this before starting!

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

CPE Summer 2015 Exam I (150 pts) June 18, 2015

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

CASPER COLLEGE COURSE SYLLABUS MSFT 1600 Managing Microsoft Exchange Server 2003 Semester/Year: Fall 2007

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

CPT101- Principles of Programming

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

CS101 PLEDGED SPRING 2001

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

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

CSci 1113 Final. Name: Student ID:

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.7. User Defined Functions II

University of Dublin

CS 101 Computer Programming and utilization. Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal Rekhi Building IIT Bombay

Read this before starting!

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS COSC 1320: INTRODUCTION TO C++ PROGRAMMING COMPUTER TECHNOLOGY & OFFICE ADMINISTRATION DEPARTMENT

CSCI 111 First Midterm Exam Spring Solutions 09.05am 09.55am, Wednesday, March 14, 2018

CS150 Sample Final Solution

Name Section: M/W or T/TH. True or False (14 Points)

Fundamentals of Programming CS-110. Lecture 2

Final Exam. Name: Student ID: Section: Signature:

Total. Name: Signature: Circle course section: MW 1-3 TTh 11-1 TTh 4-6

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15)

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 03

CSCE 206: Structured Programming in C++

Chapter 17 - Notes Recursion

The Linux Command Line: A Complete Introduction, 1 st ed., by William E. Shotts, Jr., No Starch Press, 2012.

Read this before starting!

Multiple Choice Questions (20 questions * 6 points per question = 120 points)

Chapter 1: Why Program? Computers and Programming. Why Program?

CSCI544, Fall 2016: Assignment 1

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

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

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Transcription:

Final Exam, Version 2 CSci 127: Introduction to Computer Science Hunter College, City University of New York 13 December 2017 Exam Rules Show all your work. Your grade will be based on the work shown. The exam is closed book and closed notes. When taking the exam, you may have with you pens, pencils, and an 8 1/2 x 11 piece of paper filled with notes, programs, etc. You may not use a computer, calculator, tablet, smart watch, or other electronic device. Do not open this exam until instructed to do so. Hunter College regards acts of academic dishonesty (e.g., plagiarism, cheating on examinations, obtaining unfair advantage, and falsification of records and official documents) as serious offenses against the values of intellectual honesty. The College is committed to enforcing the CUNY Policy on Academic Integrity and will pursue cases of academic dishonesty according to the Hunter College Academic Integrity Procedures. I understand that all cases of academic dishonesty will be reported to the Dean of Students and will result in sanctions. Name: EmpID: Signature:

1. (a) What will the following Python code print: s = "history.biology.science." num = s.count(".") subjects = s[:-1].split(".") print("there are", num, \ "important subjects in school.") mess = subjects[:-1]: for item in mess: print("don t know much about", item) print("but I do know that", \ "I love computer " + subjects[2]) (b) Consider the following shell command and resulting output: ls *.py averageimage.py copenhagentransit.py gccontent.py averageimageanswer.py cropimage.py growingspiral.py blueimage.py cropimage2.py triangles.py i. What is the output for: ls *wing*.py ii. What is the output for: ls *.py grep age 1

2. (a) After executing the Python code, write the name of the turtle: i. which is white: import turtle turtle.colormode(255) amy = turtle.turtle() amy.color("#ffffff") beth = turtle.turtle() beth.color(0,255,255) meg = turtle.turtle() meg.color("#ff0000") lisa = turtle.turtle() lisa.color(100,100,100) ii. which is gray: iii. which is teal (blue-green): iv. which is brightest red: (b) Write the Python code for the following algorithm: function makeuppercase(inmsg) create an empty message for each letter in inmsg: code = the Unicode of the letter if code >= 97 code = code - 32 convert the code to the corresponding Unicode character concatenate the character to the beginning of the message return the message 2

3. (a) What is the value (True/False) of out: i. ii. iii. in1 = True in2 = False out = in1 or in2 in1 = True in2 = False out = in1 and not (in1 or in2) in1 = True in2 = True in3 = (in1 or in2) out = in1 and not in3 out = out = out = iv. out = in1 = False in2 = True (b) Design a circuit that takes three inputs that: returns true if all three inputs are true, and returns false otherwise. 3

4. (a) Draw the output of the program: #Mystery program... import turtle th = turtle.turtle() for i in range(5): th.forward(100) th.left(720/5) (b) What is the output: #Mystery program def select(nums): m = nums[0] for n in nums: if n < m: m = n print(m) return(m) i. For truncate([10,2])? ii. For truncate([7,2,0,1])? def truncate(userlist): if len(userlist) < 5: best = select(userlist) else: best = select(userlist[2:]) print("best is", best) iii. For truncate([0,2,10,9,1,-1])? 4

5. Write a complete Python program that asks the user for the name of a png file and prints the number of pixels that are very purple (the fraction of red and the fraction of blue are both above 0.75 and the fraction of green is below 0.25). 5

6. Write a complete Python program that will read: prompt the user for the name of a CSV file, prompt the user for the name of a column in that CSV file, and print out the minimum and maximum values of that column. 6

7. Fill in the following functions that maps GIS data from NYC OpenData CSV files: getlocale(): asks and returns the user for latitude and longitude, makemap(): returns a map, centered at the current location, and addmarkers(): adds markers, from the GIS locations in a DataFrame to the map. import pandas as pd import folium def getlocale(): """ Asks the user for latitude and longitude of the user s current location and Returns those floating points numbers. """ def makemap(x,y): """ Makes a map, m, centered at (x,y) and Returns m """ def addmarkers(m,df): """ Adds to map, m, markers for locations in columns df[ Lat ] and df[ Lon ] Returns m """ 7

8

8. (a) What are the values of register, $s0 for the run of this MIPS program: #Sample program that loops from 50 down to 0 ADDI $s0, $zero, 50 #set s0 to 50 ADDI $s1, $zero, 10 #use to decrement counter, $s0 AGAIN: SUB $s0, $s0, $s1 BEQ $s0, $zero, DONE J AGAIN DONE: #To break out of the loop Values of $s0: (b) Write a MIPS program where the register, $s0 loops through the values: 1,3,5,7 9

9. What is the output of the following C++ programs? (a) //Derek Bok #include <iostream> using namespace std; int main() { cout << "If you think education" << endl; cout << " is expensive,\n Try "; cout << "ignorance.\n"; } (b) //Mystery C++, #2 #include <iostream> using namespace std; int main() { int count = 0; while (count < 4) { cout << count<< endl; count = count + 2; } cout<<"up!\n"; } (c) //Mystery C++, #3 #include <iostream> using namespace std; int main() { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) if ((i+j) % 2 == 0) cout << "+"; else cout << "-" cout << endl; } } 10

10. (a) Write a complete Python program to print the fine for speeding. The program must read the speed from user input, then compute and print the fine. The fine is $10 for each mph over 55 and less than or equal to 65, and $15 for each additional mph over 65. For example, if the speed is 58 mph, then the fine would be $30 = $10 x 3. If the speed is 67 mph, then the fine would be $130 = $10 x 10 + $15 x 2. (b) Write a complete C++ program that repeatedly prompts the user for their planned graduation year as a number until they enter a number that is 2017 or larger. Your program should print out the final number the user entered: 11