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

Mock Final Exam 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 2 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 1 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 Department of Computer Science & Engineeringt CSCI &09 Dr. KHALIL Exam-I Fall 2009

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

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.

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

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

Section 001. Read this before starting!

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

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.

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

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

CSci 127: Introduction to Computer Science

Read this before starting!

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

Read this before starting!

EE 109 Lab 8a Conversion Experience

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

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

CS150 Sample Final. Name: Section: A / B

VARIABLES & ASSIGNMENTS

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

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

CS150 Sample Final Solution

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

Algorithmic Approaches for Biological Data, Lecture #1

CSCE Practice Midterm. Data Types

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

In this chapter you will learn:

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

THE UNIVERSITY OF TRINIDAD & TOBAGO

CSci 127: Introduction to Computer Science

CS150 - Sample Final

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

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

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6

Final Examination Semester 2 / Year 2005

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

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

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop

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

Read this before starting!

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

To become familiar with array manipulation, searching, and sorting.

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

OPEN BOOK, OPEN NOTES. NO COMPUTERS, OR SOLVING PROBLEMS DIRECTLY USING CALCULATORS.

Perfect square. #include<iostream> using namespace std; int main(){ int a=1; int square; while(true){ } cout<<square<<endl; }

Read this before starting!

Computer Programming. Dr. Fahad Computer Science Deptt.

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

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

Sample Examination. Family Name:... Other Names:... Signature:... Student Number:...

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Tutorial Letter 103/1/2017 Introduction to Programming I

a. a * c - 10 = b. a % b + (a * d) + 7 =

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

Exam 1 Practice CSE 232 Summer 2018 (1) DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

CS Semester I. Quiz 1 (version A)

CSCI 111 Second Midterm Exam Spring Solutions 09.00am 09.50am, Wednesday, May 10, 2017

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

LAB 4.1 Relational Operators and the if Statement

East Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2006

Python: common syntax

Study Guide for Test 2

Lecture 1. Course Overview, Python Basics

Shell / Python Tutorial. CS279 Autumn 2017 Rishi Bedi

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

CSCE Practice Midterm. Data Types

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

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

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11

Functions. CS111 Lab Queens College, CUNY Instructor: Kent Chin

Read this before starting!

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

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

Read this before starting!

Reading from and Writing to Files. Files (3.12) Steps to Using Files. Section 3.12 & 13.1 & Data stored in variables is temporary

Introduction to Lab Sessions

CSCE 206: Structured Programming in C++

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, November 24, 2015

CS 100: Gates and Drawing and Turtles

CSCI544, Fall 2016: Assignment 1

CIS 110 Introduction to Computer Programming. 17 December 2012 Final Exam

East Tennessee State University Department of Computer and Information Sciences CSCI 4717 Computer Architecture TEST 3 for Fall Semester, 2005

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

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

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

Lecture 1. Course Overview, Python Basics

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

Transcription:

Final Exam, Version 4 CSci 127: Introduction to Computer Science Hunter College, City University of New York 20 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: wlist = "Mon&Tues&Wednes&Thurs&Fri&Satur&Sun" weeks = wlist.split("&") tgit = weeks[3] print(tgit.upper()) print(weeks[-1]) for i in range(0,6,2): day = weeks[i]+"day" print(i,day) (b) Consider the following shell commands: $ ls map.html map.py p10.py i. What is the output for: $ cp p10.py p11.py $ mkdir maps $ ls ii. What is the output for: $ mv p10.py map2.py $ mv m*.* maps $ ls 1

2. (a) Fill in the missing values in the table: Decimal Binary Hexadecimal 4 4 101 5 14 1110 32 100000 11111111 FF (b) Fill in the code below to make an image in which a pixel is blue if it has an entry of 10 or less in the array elevations. Otherwise, the pixel should be colored green. # Takes elevation data of NYC and displays storm surge map import numpy as np import matplotlib.pyplot as plt elevations = np.loadtxt( elevationsnyc.txt ) #Base image size on shape (dimensions) of the elevations: mapshape = elevations.shape + (3,) floodmap = np.zeros(mapshape) for row in range(mapshape[0]): for col in range(mapshape[1]): #Save the image: plt.imsave( floodmap.png, floodmap) 2

3. (a) What is the value (True/False) of out: i. ii. iii. in1 = True in2 = False out = in1 and in2 in1 = False in2 = False out = in1 and (in2 or not in1) in1 = True in2 = False 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 and returns true when two or more of the inputs are true. Otherwise if returns false. 3

4. (a) Draw the output of the program: #turtle mystery import turtle tess = turtle.turtle() for i in range(8): if i%2 == 0: tess.stamp() tess.forward(100) tess.left(45) (b) What is the output: #Another mystery program... #mystery def dub(num): send = chr(num) if num < ord( k ): send = send + send return send def enigma(letters): mess = "" for l in letters: n = ord(l) c = dub(n) mess = mess + c return mess word = input( Enter a word: ) s = enigma(word) print( Output is:, s) i. When the user enters: aa? ii. When the user enters: cab? iii. When the user enters: alice? 4

5. 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 maximum value and the average of the column. 5

Name: EmpID: CSci 127 Final, V4, F17 6. Write a complete Python program that asks the user for the name of a.png (image) file and displays the lower left quarter of the image. For example if the image is hunterlogo.png (left), the displayed image would be (right): 6

7. Complete the following Python program, which asks the user for the number of turtles to create and creates them. Then, repeats 10 times, moving each turtle in the list forward and stamping. That is, write the functions getinput(), moveforward(), and stamp(): #Intro Programming Lab: A program with herd of turtles import turtle def setupturtles(n): tlist = [] #Create turtles: for i in range(n): t = turtle.turtle() t.shape("turtle") tlist.append(t) return tlist def main(): num = getinput() #Ask for number of turles turtlelist = setupturtles(numturtles) #Make a list of num turtles for i in range(10): #Repeat 10 times moveforward(turtlelist) #Move each turtle in the list forward stamp(turtlelist) #Stamp where the turtle stopped if name == " main ": main() 7

8. (a) What are the values of register, $s0, and output for the run of this MIPS program: #Set up counters: ADDI $s0, $zero, 3 ADDI $s1, $zero, 1 AGAIN: ADDI $sp, $sp, -4 ADDI $t0, $zero, 66 # B SB $t0, 0($sp) ADDI $t0, $zero, 121 # y SB $t0, 1($sp) ADDI $t0, $zero, 101 # e SB $t0, 2($sp) ADDI $t0, $zero, 0 # (null) SB $t0, 3($sp) ADDI $v0, $zero,50 #50 is for printing message ADDI $a0, $sp, 0 syscall SUB $s0, $s0, $s1 BEQ $s0, $zero, AGAIN Values of $s0: (b) Write a MIPS program that prints the letter B 10 times: 8

9. What is the output of the following C++ programs? (a) //Eleanor Roosevelt #include <iostream> using namespace std; int main() { cout << "Do one thing, every " << endl; cout << "day,\n that"; cout << "scares you.\n"; (b) //Mystery C++, #2 #include <iostream> using namespace std; int main() { int sum = 1; while (sum < 10) { cout << sum; sum = sum + sum; (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 % 2 == 0) cout << "+"; else cout << "-"; cout << endl; 9

10. (a) Write a complete Python program that prompts the user to the year they were born. If the user enters a number larger than 2017, your program should continue prompting the user until they enter a number less than or equal to 2017. Your program should then print out the number entered. (b) Write a complete C++ program that asks the user for a number and prints Days if the number entered is less than 7, Week if the number is exactly 7, and More otherwise. 10