h01: Perkovic Ch1 (Introduction to CS), 2.1, 2.2 (Expr, Vars, Assignment, Strings), 2.3 (Lists, Tuples)

Similar documents
Scarborough Spring 2013 Math Exam I 1. "On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work.

March Madness Basketball Tournament

NCSS Statistical Software

March Madness Basketball Tournament

COURSE SYLLABUS FOR ALH A111 - MEDICAL TERMINOLOGY. Spring, :30-5:40 pm Mondays CRN#: Orange Coast College, Science Hall

Desert Premier League Roster Freeze

FRA SUMMER MATH 2017 Math Course 3

Computational Models: Class 6

Week 1, Lesson Plan for Success 2. Interactive Notebook 3. HW: Factoring Worksheet. Alg 4 Questionaire.2.docx.

Orion Scoring System. Target Management and Use at Georgia 4-H Events

Iteration: while, for, do while, Reading Input with Sentinels and User-defined Functions

WEST POINT GOLF CLUB USING THE GOLFSOFTWARE PROGRAM FOR THE DRAW AND SCORING

Write Your Own Twine Adventure!

Mac Software Manual for FITstep Pro Version 2

Club s Homepage Use this feature to return the club s website.

MEETPLANNER DESIGN DOCUMENT IDENTIFICATION OVERVIEW. Project Name: MeetPlanner. Project Manager: Peter Grabowski

CMSC131. Introduction to Computational Thinking. (with links to some external Scratch exercises) How do you accomplish a task?

Math Released Item Grade 4 PBA Item #17 Number of Baskets VF565302

The Game of Yinsh (Phase II)

Handicapping Process Series

We release Mascot Server 2.6 at the end of last year. There have been a number of changes and improvements in the search engine and reports.

Software Manual for FITstep Pro Version 2

Previous Release Notes

Thank you for choosing AIMS!

DESIGN AND ANALYSIS OF ALGORITHMS (DAA 2017)

The Math and Science of Bowling

Professional Gunsmithing: A Textbook On The Repair And Alteration Of Firearms PDF

Lesson 12 New Procedure PULMONARY FUNCTION I

NONLOCALITY AND OBJECT ORIENTED PROGRAMMING

Preparing Questions for Brownstone's Software Formats:

The Race Director. IPICO Integration Direct Connect [IPICO INTEGRATION]

a fraction rock star in no time! This is a free calculator for adding, subtracting, multiplying, and dividing two fractions and/or mixed numbers.

Lesson 6: Measuring Distances Less Than 1

Cambridge International Examinations Cambridge Primary Checkpoint

Instruction Guide for using Dive Tables (draft)

Gas volume and pressure are indirectly proportional.

Basic CPM Calculations

Exp. 5 Ideal gas law. Introduction

News English.com Ready-to-use ESL / EFL Lessons

Golf Trip Captain s Guide

English 2321 Readings in British Literature

IMGA PAIRINGS INSTRUCTIONS USING the ONLINE GOLF GENIUS SOFTWARE ROGRAM Revised as of 12/31/2017

Briggs Chaney Middle School. Summer Math Packet Incoming Grade 6

Cuneiform. A Functional Workflow Language Implementation in Erlang. Jörgen Brandt Humboldt-Universität zu Berlin

Lesson 14: Modeling Relationships with a Line

Introduction to Matlab for Engineers

BIOLOGY OF THE INVERTEBRATES BY JAN PECHENIK DOWNLOAD EBOOK : BIOLOGY OF THE INVERTEBRATES BY JAN PECHENIK PDF

[CROSS COUNTRY SCORING]

Pace Handicapping with Brohamer Figures

ISO 2944 INTERNATIONAL STANDARD. Fluid power systems and components Nominal pressures. Transmissions hydrauliques et pneumatiques Pressions nominales

Program Design and Objects. Wrestling with Python

EXPERIMENT XI. Careful!! Improper handling of the vacuum line may result in the release of SO 2 which is an irritating and suffocating gas.

Microsoft Windows Software Manual for FITstep Stream Version 4

Modern Control Systems (13th Edition)

Advanced Handicapping Quirin Speed Points The Basics

Math Released Item Grade 4 M03436

Extending the Number System

Assignment for Next Class. Information Systems ISM Put In Nonsense, Get Out Chaos. System and Modeling Concepts. Components of a System.

The Art Of War By Sun Tzu (English And Mandarin Chinese Edition) By Sun Tzu, Lionel Giles READ ONLINE

USA league season. Referee procedures and game check in procedures.

Lesson 2 Pre-Visit The Negro Leagues

Ideal gas law. Introduction

[XACT INTEGRATION] The Race Director. Xact Integration

Version 3.1.0: New Features/Improvements: Improved Bluetooth connection on Windows 10

AGA Swiss McMahon Pairing Protocol Standards

All About. By. Stephanie Stewart Falling Into First

UNIVERSITY OF CAMBRIDGE INTERNATIONAL EXAMINATIONS General Certificate of Education Ordinary Level

Where are you right now? How fast are you moving? To answer these questions precisely, you

Traveling Waves vs. Standing Waves

USER MANUAL April 2016

E-COMMERCE 2013 (9TH EDITION) BY KENNETH C. LAUDON, CAROL GUERCIO TRAVER

1 8 Practice Perimeter Circumference And Area Answers Form G

Mathematical Analysis: A Concise Introduction By Bernd S. W. Schröder

9A Gas volume and pressure are indirectly proportional.

INSTRUCTIONS FOR USING HMS 2016 Scoring (v1)

BEST PRAXIS II SOCIAL STUDIES STUDY PART LIST DOCUMENT

FEATURES. Features. UCI Machine Learning Repository. Admin 9/23/13

HOW TO SUBMIT YOUR RACE RESULTS ONLINE?

CS 341 Computer Architecture and Organization. Lecturer: Bob Wilson Cell Phone: or

The use of Control Charts with Composite materials. E. Clarkson, Statistician ASQ Certified Quality Engineer

FIG1 Screen 26 Aug 07

Lesson 2 Pre-Visit Step Up to the Plate for Baseball Idioms

Helium: A Data Driven User Tool for SAR Analysis. May 17 th 2011 Karen Worsfold

July 2010, Number 58 ALL-WAYS TM NEWSLETTER

Algebra Date Lesson Independent Work Computer Tuesday, Introduction (whole class) Problem with Dice

An exploration of how the height of a rebound is related to the height a ball is dropped from. An exploration of the elasticity of rubber balls.

A Student's Guide To Waves Download Free (EPUB, PDF)

Click IRB Resources Frequently Asked Questions

The MACC Handicap System

You are to develop a program that takes as input the scorecard filled out by Bob and that produces as output the correct scorecard.

RUNNING A MEET WITH HY-TEK MEET MANAGER

Couples, Relations and Functions

Shearwater GF Computer

EEC 686/785 Modeling & Performance Evaluation of Computer Systems. Lecture 6. Wenbing Zhao. Department of Electrical and Computer Engineering

2018 Annual Dance Concert Orientation Package. What is included in each Performance Package?

A Hare-Lynx Simulation Model

News English.com Ready-to-use ESL / EFL Lessons

SURFACE CASING SELECTION FOR COLLAPSE, BURST AND AXIAL DESIGN FACTOR LOADS EXERCISE

Solar Water Heaters for Swimming Pools

Performance of Fully Automated 3D Cracking Survey with Pixel Accuracy based on Deep Learning

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" @umail.ucsb.edu : Perkovic Ch1 (Introduction to CS), 2.1, 2.2 (Expr, Vars, Assignment, Strings), 2.3 (Lists, Tuples) ready? assigned due points true Tue 08/07 09:30AM Tue 08/14 09:30AM 270 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 read Chapter 1 in Perkovic. 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. Section 1.1 describes Computer Science in general. It includes a passage that distinguishes between models, algorithms and programs. I'm going to ask two questions about the relationships among these concepts. In your answer, don't just copy down an exact quote from the textbook; explain in your own words. If you don't think you understand the relationship, be honest about that, and write down what you are confused about, or your best guess at what the author is trying to say. a. (5 pts) What is the relationship between a model and an algorithm? b. (5 pts) What is the relationship between an algorithm and a program? 3. (10 pts) Section 1.2 describes Computer Systems in general. According to our author, why did computer scientists create programming languages such as Python, C, C++, Java, etc.? 1 of 6

4. Continuing with questions from Section 1.2: a. (10 pts) The author makes a distinction between the "core set" of features in a programming language, and those that are put into "software libraries". What are two examples of features that end up in libraries rather than in the core language? b. (10 pts) What is the advantage of putting those features into libraries rather than into the core? c. (10 pts) APIs (Application Programming Interfaces) are important in programming our author gives a nice clear explanation of what an API is. What is that explanation? 2 5. Section 1.3 describes the Python programming language. a. (10 pts) What is the interactive shell used for? b. (10 pts) What does a Python program consist of? 6. Section 1.4 contains a description of a sample problem that the author uses to illustrate "computational thinking". The author notes that in applying computational thinking to a problem, one of the steps we take is to decide which details of the problem are important, and which are not. a. (10 pts) Give two examples of details about the problem statement that, according to the author's discussion, are not relevant, and should be ignored. b. (10 pts) Give two examples of details that are definitely relevant, and that we need to pay attention to in coming up with a solution. 2 of 6

READING ASSIGNMENT Please read Perkovic 2.1, 2.2 (Expr, Vars, Assignment, Strings). Then complete these problems. 7. Section 2.1 describes how several operators and built in functions in Python work. What would be the result of entering the following at the Python interactive shell prompt? (Note: You are encouraged to check your answers at the Python prompt before turning in your work, but try this on paper first, just by reading the text and trying to predict what will happen. Then try typing in the results at the Python prompt. Change your answers if they were mistaken, but even more important, try to figure out why you were incorrect.) Be very precise. Note that True is not the same in Python as true; upper vs. lower case matters. You will not get full credit for answers that are not precisely correct. Points Expression Result Points Expression Result (4 pts) 2 + 3 * 5 (4 pts) 4 < 3 (4 pts) 19 % 3 (4 pts) 1 + 2 == 3 3 (4 pts) 5 ** 2 (4 pts) True and False (4 pts) 7 // 2 (4 pts) True or False (4 pts) 9 // 2 (4 pts) 5!= 10//2 3 of 6

8. (5 pts) As described in section 2.1, a Python assignment statement contains the assignment operator, an expression and a variable, but not in that order. What is the correct order for these three parts, reading from left to right? 9. (5 pts) Section 2.1 contains a list of thirty-three reserved words in Python that may not be used as the name of a variable. You don t need to memorize this list, but you do need to know where to find it, either in the book, or online. So, to be sure you can find it, list all of the Python reserved words that start with the letter c or f. 10. Section 2.2 describes strings in Python, including the concepts of dictionary order (also called lexicographic order ), concatenation of strings, multiplication of strings times an integer, the in operator, the not in operation, the len function, and string indexing. Review that material. 4 Then, assuming the following assignment statements have been entered at the Python prompt: school = "UCSB" course = "CS8" qtr = "M17" Indicate the value of each of these expressions: Expression Result Expression Result (4 pts) school * 2 (4 pts) school > course (4 pts) qtr[1:3] (4 pts) qtr < school (4 pts) course[0:2] (4 pts) len(qtr) > 4 (4 pts) 'D' in school (4 pts) school[-1] (4 pts) 'E' not in school (4 pts) school[0] 4 of 6

READING ASSIGNMENT Please read Perkovic 2.3 (Lists, Tuples). Then complete these problems. 11. Section 2.3 describes lists and tuples in Python. Assuming the following assignment statements have been entered at the Python prompt: schools = ("UCSB","Stanford","UCLA","UCSD","Cal Tech") schedules = [ ["CMPSC 8","MATH 3A"], ["CMPSC 8","PSTAT 5A"],["MATH 3B"] ] units = [8, 8, 4] What would be the result of entering the following at the Python interactive shell prompt? (Note: You are encouraged to check your answers at the Python prompt before turning in your work, but try this on paper first, just by reading the text and trying to predict what will happen. Then try typing in the results at the Python prompt. Change your answers if they were mistaken, but even more important, try to figure out why you were incorrect.) Be very precise. Note that True is not the same in Python as true; upper vs. lower case matters. You will not get full credit for answers that are not precisely correct. And note that "UCSB" and ["UCSB"] are not the same in Python one is a string, and the other is a list of length one containing a single string. 5 Points Expression Result Points Expression Result (4 pts) len(schedules) (4 pts) sum(units) (4 pts) len(units) (4 pts) "CMPSC 8" in schedules[0] (4 pts) len(schedules[1]) (4 pts) "UCSD" in schools (4 pts) len(schools[-1]) (4 pts) "U" in schools[1] (4 pts) min(units) (4 pts) "MATH 3A" in schedules 5 of 6

12. (5 pts) As described in section 2.3, lists and tuples are similar, but there are two big differences. One is that lists are written with square brackets [] while tuples are written with parentheses (). What is the other big difference between lists and tuples? 13. (5 pts) Write a line of Python code that assigns the variable myschool to have a value that is a tuple of length 1, containing the single string "UCSB". 6 14. Assume that the following sequence of statements has been entered at the Python prompt. Note that subsequent statements may change the value of the variables (e.g. colors is altered by the call to the append method) colors = ["red","red","green"] colors.append("blue") colors.reverse() Points Expression Result Points Expression Result (4 pts) len(colors) (4 pts) colors[-1][-1] (4 pts) colors[0] (4 pts) colors[2][0] (4 pts) colors.count("red") (4 pts) "blue" not in colors (4 pts) colors.count("blue") (4 pts) colors.count(colors[-1]) (4 pts) len(colors[1]) (4 pts) "e" in colors[0] 6 of 6