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

Similar documents
Mock Final Exam 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

Mock Final Exam 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

Final Exam, Version 2 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 2 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

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

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

CSci 127: Introduction to Computer Science

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

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

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. Instructor: Final Exam Fall Section No.

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

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

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

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

CSci 127: Introduction to Computer Science

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

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

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

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

CSci 127: Introduction to Computer Science

CSci 127: Introduction to Computer Science

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

Algorithmic Approaches for Biological Data, Lecture #1

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

Read this before starting!

Final Examination Semester 2 / Year 2005

CS150 Sample Final. Name: Section: A / B

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

Learning Recursion. Recursion [ Why is it important?] ~7 easy marks in Exam Paper. Step 1. Understand Code. Step 2. Understand Execution

Read this before starting!

Answer Key: CIS 166 Final Exam, Version 1, Spring 2015

CSCI544, Fall 2016: Assignment 1

Programming Language. Functions. Eng. Anis Nazer First Semester

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

In this chapter you will learn:

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

Exam I Computer Science 420 Dr. St. John Lehman College City University of New York 12 March 2002

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

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

Read this before starting!

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

Using the Xcode Debugger

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

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

York University. AP/ITEC Section M INTRODUCTION TO DATA STRUCTURES Winter Midterm Test

SAMPLE EXAM Exam 2 Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 5 November 2009

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

CSCE 2014 Final Exam Spring Version A

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

CSci 1113 Midterm 1. Name: Student ID:

Control Flow: Loop Statements

CS150 Sample Final Solution

COMP322 - Introduction to C++ Lecture 01 - Introduction

Problem Solving: Storyboards for User Interaction

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

Solve only 2 out of 3 questions

(the bubble footer is automatically inserted into this space)

Computer Programming

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

CSCI 528: OBJECT ORIENTED PROGRAMMING, Fall 2015

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

MWF 9:00-9:50AM & 12:00-12:50PM (ET)

Section 001. Read this before starting!

CSCI-1200 Data Structures Fall 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

CSCE 206: Structured Programming in C++

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

2. For each of the regular expressions, give a string that will matches it:

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

CS 2316 Exam 3. Practice. Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score.

Read this before starting!

CSE 303, Winter 2007, Final Examination 15 March Please do not turn the page until everyone is ready.

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

VARIABLES & ASSIGNMENTS

CSCI-1200 Data Structures Fall 2017 Lecture 7 Order Notation & Basic Recursion

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS. ITNW 2313: NETWORKING HARDWARE Online Course Version COMPUTER TECHNOLOGY DEPARTMENT

Section 001. Read this before starting! You may use one sheet of scrap paper that you will turn in with your test.

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS. ITNW 1354: IMPLEMENTING AND SUPPORTING SERVERS Previously ITMC 1341 and then ITMT 1340

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

Linked List using a Sentinel

CSI33 Data Structures

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

Tutorial Letter 103/1/2017 Introduction to Programming I

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes

CSCI 111 Midterm 2 Exam Spring Solutions 09.00am 09.50am, Wednesday, May 04, 2016

CSci 1113 Final. Name: Student ID:

East Tennessee State University Department of Computer and Information Sciences CSCI 1710/Section 001 Web Design I TEST 1 for Fall Semester, 2000

Minot State University BUSINESS INFORMATION TECHNOLOGY DEPARTMENT Course Outline

CISN 340 Data Communication and Networking Fundamentals Fall 2012 (Hybrid)

ESE532 Fall University of Pennsylvania Department of Electrical and System Engineering System-on-a-Chip Architecture

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

Exam II CIS 228: The Internet Prof. St. John Lehman College City University of New York 5 November 2009

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14

CASPER COLLEGE COURSE SYLLABUS BIOL 1000, Introduction to Biology I

Transcription:

Mock Final Exam CSci 127: Introduction to Computer Science Hunter College, City University of New York 15 May 2018 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 exams 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: i. s = "Ada:)Lovelace:)Grace:)Hopper" a = s[0:3] print(a.upper()) ii. names = s.split(":)") print(names[-1]) iii. b,c,d = names[1],names[2],names[3] print(b,d) iv. print(b[-1]+"n"+d[-2]+"ine") print( Put_line: (", a.lower(), ") ) (b) Consider the following shell commands: $ ls -l *z* -rw-r--r--@ 1 stjohn staff 5308 Mar 21 14:38 quizzes.html -rw-r--r-- 1 stjohn staff 54013 Mar 20 18:57 zonedist.csv -rw-r--r--@ 1 stjohn staff 1519 Mar 22 15:14 zonemap.py -rw-r--r-- 1 stjohn staff 16455174 Mar 20 19:02 zoning2.html -rw-r--r-- 1 stjohn staff 17343896 Mar 20 18:58 zoningids.json i. What is the output for: $ ls -l *z* grep ".html" ii. What is the output for: $ ls -l *z* grep ".html" wc -l 1

2. (a) Fill in the missing code below: #Demonstrates colors, using turtles import turtle tess = turtle.turtle() #Set color of tess to blue: #Set color of tess to maximum red, maximum blue, and no green: #Set color of tess using hexcodes: red, green, and blue all equal to "A0": (b) Write the Python code for the following algorithm: Ask user for input, and store in the string, binstring. Set decnum = 0. For each c in binstring, Set n to be int(c) Double decnum and add n to it (decnum = 2 * decnum + n) Print decnum 2

3. (a) What is the value (True/False): i. ii. iii. in1 = False in2 = True out = in1 and in2 in1 = False in2 = True out = not in1 or (in2 and not in1) in1 = False in2 = False or not in1 in3 = in1 and in2 out = in1 and not in3 out = out = out = iv. in1 = True in2 = False out = (b) Design a circuit that implements the logical expression: ((not in1) and (in1 or not in2)) and (in3 or not in3) 3

4. (a) Draw the output for the function calls: import turtle tess = turtle.turtle() tess.shape("turtle") def ramble(t,length): if length < 10: t.stamp() else: t.forward(length) t.left(90) ramble(t,length-10) i. ramble(tess,0) ii. ramble(tess,50) (b) What is returned when the function is invoked on the inputs below: def gee(a,b): while a!= b: if a > b: a = a - b else: b = b - a return a i. gee(1,1) Return: ii. gee(2,3) Return: iii. gee(2,4) Return: iv. gee(16,24) Return: 4

5. Write a complete Python program that uses folium to make a map of New York City. Your map should be centered at (40.75, 74.125) and include a marker for the main campus of Hunter College. The HTML file your program creates should be called: nycmap.html. 5

6. Using matplotlib.pyplot and numpy, write a complete Python program that reads in an array (grid) of elevations, elevations.txt. Your program should create an image where for each element of the array, the corresponding pixel is colored in the final image is: colored blue if the elevation is 0 or less, black if the elevation is positive and divisible by 10, and gray otherwise. Your resulting image should be stored in a file, topomap.png. 6

7. Fill in the following functions that are part of a program that analyzes NYC Urban Forest of street trees (from NYC OpenData): getdata(): asks the user for the name of the CSV file and returns a DataFrame of the contents. totaltrees(): returns the number of trees (length) in the DataFrame, and biggestdiameter(): returns the largest diameter (tree dbh) in the DataFrame. import pandas as pd def getdata(): Asks the user for the name of the CSV and Returns a dataframe of the contents. def totaltrees(df): Takes a DataFrame as input. Returns the length of the DataFrame. def biggestdiameter(df): Takes a DataFrame as input. Returns the maximum value in the column, tree_dbh.. 7

8. (a) What is the output for a run of this MIPS program: # Store Help!! at the top of the stack ADDI $sp, $sp, -7 ADDI $t0, $zero, 72 # H SB $t0, 0($sp) ADDI $t0, $zero, 101 # e SB $t0, 1($sp) ADDI $t0, $zero, 108 # l SB $t0, 2($sp) ADDI $t0, $zero, 112 # p SB $t0, 3($sp) ADDI $t0, $zero, 33 #! SB $t0, 4($sp) ADDI $t0, $zero, 33 #! SB $t0, 5($sp) ADDI $t0, $zero, 0 # (null) SB $t0, 6($sp) ADDI $v0, $zero, 4 # 4 is for print string ADDI $a0, $sp, 0 syscall # print to the log (b) Write a MIPS program that prints: Hi! Hi! 8

9. What is the output of the following C++ programs? (a) //Lewis Carroll, Alice in Wonderland #include <iostream> using namespace std; int main() { cout << "Take care of the sense, "<< endl; cout << "and the sounds will \n take care"; cout << "of themselves." << endl cout << endl; } (b) //Lewis Carroll, more Alice... #include <iostream> using namespace std; int main() { int count = 2; while (count > 0) { cout <<"Twinkle, "; count--; } cout << "little bat!" } (c) //Stars and more stars #include <iostream> using namespace std; int main() { int i, j; for (i = 1; i <= 5; i++) { for (j = 1; j <= i; j++) cout << "*"; cout << endl; } } 9

10. (a) Write a complete Python program that prompts the user for a string and then prints the string in reverse. For example, if the user entered, Python, your program would print: nohtyp. (b) Write a complete C++ program that prints the spread of disease, following the Susceptible, Infected, Recovered (SIR) model: S =.95S I = I +.05S.04I R = R +.04I where S is the size of the susceptible population, I is the number of currently infected in the population, and R is the number who have recovered. Each day, 4% of those ill recover and 5% of the susceptible population becomes infected. Assume that the starting susceptible population at year 0 is 1000 with 100 infected and 100 recovered. Your program should print for the first 10 days: the day, the number of susceptible population, the number currently infected, and the number who have recovered. 10