Also: JUST write your name at the top of all sheets and turn in all sheets UNCONNECTED.

Similar documents
CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Wednesday, 11/18/2009

NOTE: All references to Python on this exam mean Python 3, so you should answer accordingly.

***PRACTICE EXAM 02 for*** CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Actual exam scheduled for: 11/18/2009

NOTE: All references to Python on this exam mean Python 3, so you should answer accordingly.

e01 EXAM: e01: Midterm Exam CS8 F18 Name: Umail 10/24/2018 e01 - Midterm Exam - Gauchospace Gradescope Piazza

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

15-110: Principles of Computing, Spring 2018

15-110: Principles of Computing, Spring 2018

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

CS16 Midterm Exam 2 E02, 10W, Phill Conrad, UC Santa Barbara Tuesday, 03/02/2010

CS150 Sample Final. Name: Section: A / B

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

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Assignment 2. CS 234 Fall 2018 Sandy Graham. Create()

CS8 Final Exam E03, 09M, Phill Conrad, UC Santa Barbara 09/10/2009

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

15-110: Principles of Computing, Spring Problem Set 3 (PS3) Due: Friday, February 9 by 2:30PM on Gradescope

CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

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

Final Exam 1 /12 2 /12 3 /10 4 /7 5 /4 6 /10 7 /8 8 /9 9 /8 10 /11 11 /8 12 /10 13 /9 14 /13 15 /10 16 /10 17 /12. Faculty of Computer Science

Midterm 1 1 /8 2 /9 3 /9 4 /12 5 /10. Faculty of Computer Science. Term: Fall 2018 (Sep4-Dec4) Student ID Information. Grade Table Question Score

Theory of Computations Spring 2016 Practice Final Exam Solutions

CSE P 501 Exam 8/5/04

Programming Project 1

Homework 1 Due Tuesday, January 30, 2018 at 8pm

CSE 131S Introduction to Computer Science Summer SON Exam I

Blackboard Grade Center

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

#101 Page: 1 Name: CS32 Midterm Exam. E01, W15, Phill Conrad, UC Santa Barbara

CS16 Final Exam E03, 10S, Phill Conrad, UC Santa Barbara Wednesday, 06/09/2010

CS 1110, LAB 10: ASSERTIONS AND WHILE-LOOPS 1. Preliminaries

Faculty Portal and Course Management Training for Clarendon College Faculty

CS 241 Data Organization using C

CS150 - Sample Final

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

Homework /681: Artificial Intelligence (Fall 2017) Out: October 18, 2017 Due: October 29, 2017 at 11:59PM

CS150 Sample Final Solution

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

Computer Center. Texas Tech University. Quick Reference Guide For Testing

Adding content to your Blackboard 9.1 class

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

Structure and Interpretation of Computer Programs

Quick Bank/Remote Deposit Capture Quick Guide

Computer Science Foundation Exam

Exercise #6: Sales by Item Year over Year Report

CSE 131S Introduction to Computer Science Summer SON Exam III

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

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

Homework 3: Recursion Due: 11:59 PM, Sep 25, 2018

CSI33 Data Structures

CSE 123: Computer Networks Fall Quarter, 2013 MIDTERM EXAM

CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes

CS 495 & 540: Problem Set 1

Document Manager 6.0 Users Manual by Scanlon Associates

Computer Science Foundation Exam

Midterm Exam 1 Solutions

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Structure and Interpretation of Computer Programs

COS 226 Algorithms and Data Structures Spring Midterm Exam

CSE 131 Introduction to Computer Science Fall Exam II

Content Creation and Management System CCMS and Right First Time Guide

Problem Score 1 / 27 2 / 19 3 / 16 4 / 14 code check off 5 / 22 /2 Total /100

W13:Homework:H08. CS40 Foundations of Computer Science W13. From 40wiki

Structure and Interpretation of Computer Programs Summer 2014 Midterm 2

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment)

CSE332 Summer 2012 Final Exam, August 15, 2012

e-class User Manual v11 (Sep. 2017)

CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm

COS 226 Midterm Exam, Spring 2009

PRACTICE MIDTERM EXAM #2

Computer Science E-22 Practice Final Exam

W13:Homework:H07. CS40 Foundations of Computer Science W13. From 40wiki

CSE Theory of Computing Fall 2017 Project 3: K-tape Turing Machine

: Principles of Imperative Computation, Spring Homework 3 Theory [Update 1]

CS 4349 Lecture August 21st, 2017

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

UNIVERSITY REGULATIONS

Faculty Pages on the RCC Website

Welcome to our Moodle site! What is Moodle?

Frequency Tables for Pink Scan Forms

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

CSE 401/M501 18au Midterm Exam 11/2/18. Name ID #

Homework 2 (by Ao Zeng) Solutions Due: Friday Sept 28, 11:59pm

Data Structure and Algorithm Homework #3 Due: 1:20pm, Thursday, May 16, 2017 TA === Homework submission instructions ===

How will you design your course and organize your material? Consider

Review for the Final Exam CS 8: Introduction to Computer Science, Winter 2018 Lecture #15

Self assessment due: Monday 10/29/2018 at 11:59pm (submit via Gradescope)

Site Owners: Cascade Basics. May 2017

Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab

Computer Science Foundation Exam

CS32 Final Exam. E03, F15, Phill Conrad, UC Santa Barbara

CSC 101: Lab #5 Boolean Logic Practice Due Date: 5:00pm, day after lab session

New Mexico State University. Financial Systems Administration - RMR BDMS Scan/Load and Indexing

END OF TERM 2/1/2016. Cami Narron. NCDPI Homebase Support Desk Tier 1 Consultant

Frequency Tables for Teal Scan Forms

Lecture 0 of 41: Part A Course Organization. Introduction to Computer Graphics: Course Organization and Survey

Part Tests on TBMaster

Structure and Interpretation of Computer Programs

COMP 524 Spring 2018 Midterm Thursday, March 1

Transcription:

Name: (as it would appear on official course roster) Umail address: Optional: name you wish to be called if different from name above. Optional: name of "homework buddy" (leaving this blank signifies "I worked alone" : Unix File Permisssions and Octal, Perkovic 7.1 (Encapsulation, Stack Frames), Review for final ready? assigned due points true Tue 09/04 09:30AM Tue 09/11 09:30AM 250 @umail.ucsb.edu 1 You may collaborate on this homework with AT MOST one person, an optional "homework buddy". MAY ONLY BE TURNED IN IN THE LECTURE/LAB LISTED ABOVE AS THE DUE DATE. There is NO MAKEUP for missed assignments, and you may not submit work in advance, or on behalf of another person. In place of that, we drop the lowest score (if you have a zero, that is the lowest score.) READING ASSIGNMENT Please review octal numbers and Unix file permissions, or consult this web page: https://ucsb-cs8.github.io/topics/number_conversions/ Then complete these problems: 1. Please fill in the information at the top of this homework sheet, including your name and umail address. If the other two items apply, please fill them in as well. Please do this every single time you submit homework for this class. It is important to fill in both name and umail every time, since handwriting is sometimes difficult to decipher. Having both helps us ensure you get credit for your work. You can also edit the pdf (or scan your written work after printing the pdf), and upload your homework to Gradescope instead of turning it in during class. Also: JUST write your name at the top of all sheets and turn in all sheets UNCONNECTED. DO NOT staple, paper clip, spit-fold-and-tear, or do ANYTHING that would make it difficult to automatically feed your paper through a scanner. 2. (10 pts) What is the Unix command to list your files in a way that shows the unix file permissions with strings such as rwxr-xr-x? 3. (10 pts) If there is a Unix file in my current directory called index.html and I want to set its permissions to rw-r--r-- what Unix command will do that? (The full command, not just the first word of the command). 1 of 6

Please complete each of the conversions shown. You can practice at the page: https://www.cs.ucsb.edu/~pconrad/cs8/topics/chmodquiz1/ until you are confident that you know how to solve these. 4. (10 pts) Convert rwxr-x--- from rwx format to octal: 5. (10 pts) Convert rwxr-xr-x from rwx format to octal: 2 6. (10 pts) Convert 777 from octal to rwx format: 7. (10 pts) Convert rwxrwx--- from rwx format to octal: 8. (10 pts) Convert 600 from octal to rwx format: 9. (10 pts) Convert 444 from octal to rwx format: 10. (10 pts) Convert rwx--x--x from rwx format to octal: 2 of 6

READING ASSIGNMENT Please read Perkovic 7.1 (Encapsulation, Stack Frames). Then complete these problems. 11. The second half of Section 7.1 discusses Stack Frames. Two things that can happen with a stack frame are a push event and pop event. a. (5 pts) What event in a running Python program is associated with the push of a stack frame onto the stack? b. (5 pts) What event in a running Python program is associated with the pop of a stack frame from the stack? 3 12. Section 7.1 discusses three of the most important benefits of using functions: reuse modularity, also called procedural decomposition encapsulation also called information hiding Below are some things that a programmer might say about one of the functions in the example code in the book. Indicate by circling, which benefit of functions is illustrated by the quote. Then, justify your answer with a brief explanation. That explanation should pertain specifically to the code shown, and NOT simply be a restateement of the definitions of the terms from the textbook, or copy/paste verbatim quote from the textbook. (Note it is possible there may be more than one reasonable choice among the three benefits. Choose one and support it, or circle more than one, and explain why you feel more than one applies.) a. (20 pts) The emoticon function (p. 204) can be used to draw an emoticon in the following program. The programmer doesn t even need to know how the emoticon is drawn. import turtle from turtlefunctions import emoticon fred=turtle.turtle() emoticon(fred,50,50) Reuse Modularity Encapsulation 3 of 6

b. (20 pts) The emoticon function (p. 204) can be used to draw three emoticons on the screen of three different colors, like this: import turtle from turtlefunctions import emoticon fred=turtle.turtle() fred.color("red") emoticon(fred,-150,100) fred.color("blue") emoticon(fred,150,100) fred.color("green") emoticon(fred,0,-100) Reuse Modularity Encapsulation 4 </li> c. (20 pts) In a blackjack program, instead of writing this code to deal one card to the player, and one card to the house: card = deck.pop() player.append(card) card = deck.pop() house.append(card) We can write this code: dealcard(deck, player) dealcard(deck, house) Using the function: # deal to player first # deal to house second Reuse Modularity Encapsulation def dealcard(deck, participant): 'deals single card from deck to participant' card = deck.pop() participant.append(card) return card 4 of 6

These problems are review for the final exam, and refer to material from Chapters 2-6, and section 7.1 13. (20 pts) Write an python function definition count_ae that takes one parameter s and returns 0 if s is not a string, otherwise returns the number of occurences of a and e in that string (only lowercase). For example: count_ae(-42) should return 0 count_ae("santa Ynez") should return 3 5 count_ae("santa Ana") should return 3 (the uppercase A does not count) 14. (10 pts) Write two test cases in the pytest style for count_ae 5 of 6

15. For each of the problems below, write a python functions with the name indicated that takes one parameter called alist, or test cases for those functions (in the style of pytest). In each case, you may assume alist is of type list and that all values in alist are of type int, and that alist contains at least two elements. For these problems, you don t need to check those things. Your code may not modify the list in any way. If you want to make a sorted copy of the list as a local variable, you may use this code: sortedcopy = alist[:].sort() a. (10 pts) minvalue, which returns the minimum value in the list without using the built-in function min. 6 b. (10 pts) Two test cases (in the pytest style) for minvalue c. (10 pts) avgvalue which returns the average value of the elements in the list. You may any built in functions available in Python, or compute the sum using the accumulator pattern (your choice). d. (10 pts) Two test cases (in the pytest style) for avgvalue e. (10 pts) secondsmallest which computes the second smallest element in the list (not the second smallest value). For example, secondsmallest([3,7,3]) should return 3. f. (10 pts) Two test cases (in the pytest style) for secondsmallest 6 of 6