Homework 1. Comp 140 Fall 2008



Similar documents
Introduction to Python

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Welcome to Introduction to programming in Python

Computer Science 1 CSci 1100 Lecture 3 Python Functions

Python for Rookies. Example Examination Paper

Solving Quadratic Equations by Factoring

Marginal cost. Average cost. Marginal revenue

Bank: The bank's deposit pays 8 % per year with annual compounding. Bond: The price of the bond is $75. You will receive $100 five years later.

APPLICATIONS AND MODELING WITH QUADRATIC EQUATIONS

Compsci 101: Test 1. October 2, 2013

THE FUNDAMENTAL THEOREM OF ARBITRAGE PRICING

Arithmetic Progression

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Lecture Notes on Polynomials

Lecture 14: Section 3.3

Minimax Strategies. Minimax Strategies. Zero Sum Games. Why Zero Sum Games? An Example. An Example

Introduction to Dissertations. Learning Enhancement Team

In the Herb Business, Part III Factoring and Quadratic Equations

LINES AND PLANES CHRIS JOHNSON

15-251: Great Theoretical Ideas in Computer Science Anupam Gupta Notes on Combinatorial Games (draft!!) January 29, 2012

(Refer Slide Time: 01.26)

4.1. Title: data analysis (systems analysis) Annotation of educational discipline: educational discipline includes in itself the mastery of the

Study Skills for Mathematics. Dr. Lisa O Keeffe August 2012

the recursion-tree method

EXCEL Tutorial: How to use EXCEL for Graphs and Calculations.

CSCI 1301: Introduction to Computing and Programming Summer 2015 Project 1: Credit Card Pay Off

White Paper: Enterprise Hosting 2013

Manual for SOA Exam FM/CAS Exam 2.

2. How is a fund manager motivated to behave with this type of renumeration package?

Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

SOLUTION OF A AN EQUATION IN ONE VARIABLE

An Argument for Uniform E-Discovery Practice in Cross-Border Civil Litigation

ü 6.3 The Net Present Value Investment Rule ü 4.6 Annuities

Number of Divisors. Terms. Factors, prime factorization, exponents, Materials. Transparencies Activity Sheets Calculators

Beyond Propositional Logic Lukasiewicz s System

K 1 < K 2 = P (K 1 ) P (K 2 ) (6) This holds for both American and European Options.

MATH 241: DISCRETE MATHEMATICS FOR COMPUTER SCIENCE, Winter CLASSROOM: Alumni Hall 112 Tuesdays and Thursdays, 6:00-8:15 pm

Quick Guide. Oral presentations. Four-step guide to preparing oral presentations. What is in this guide. Step 1: Plan

Lecture 7: Bounds on Options Prices Steven Skiena. skiena

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Mathematics. Mathematical Practices

CHAPTER 1. Compound Interest

TPPE17 Corporate Finance 1(5) SOLUTIONS RE-EXAMS 2014 II + III

Chapter 21: The Discounted Utility Model

Chapter 6 Cost-Volume-Profit Relationships

Mathematical Induction. Mary Barnes Sue Gordon

Fundamentals of EMR. General Homework Guidelines. There is some essential information you must include in all correspondence:

Vieta s Formulas and the Identity Theorem

Lecture 7: NP-Complete Problems

Objects and classes. Objects and classes. Jarkko Toivonen (CS Department) Programming in Python 1

6 Hedging Using Futures

Exploring Algorithms with Python

Critical Thinking. Philosophy 125

Prentice Hall Mathematics: Algebra Correlated to: Utah Core Curriculum for Math, Intermediate Algebra (Secondary)

Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari:

Library, Teaching and Learning. Writing Essays. and other assignments Lincoln University

UNIVERSITY of the FRASER VALLEY COURSE OUTLINE

Critical analysis. Be more critical! More analysis needed! That s what my tutors say about my essays. I m not really sure what they mean.

Chapter 4 -- Decimals

Section 5.0A Factoring Part 1

Math. MCC6.RP.1 Understand the concept of a ratio and use

Massachusetts Institute of Technology 6.005: Elements of Software Construction Fall 2011 Quiz 2 November 21, 2011 SOLUTIONS.

Solutions to Homework 6 Mathematics 503 Foundations of Mathematics Spring 2014

CS 1133, LAB 2: FUNCTIONS AND TESTING

From the Webisode: Math Meets Culinary Arts

Chapter 17. Orthogonal Matrices and Symmetries of Space

Lecture 15: Inheritance

BPA434: ADVANCED TOPICS IN CORPORATE FINANCE COURSE OUTLINE

def: An axiom is a statement that is assumed to be true, or in the case of a mathematical system, is used to specify the system.

Propositional Logic. A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both.

Assignment 2: Option Pricing and the Black-Scholes formula The University of British Columbia Science One CS Instructor: Michael Gelbart

Home Assignment 4 OCL

Guide for the Personal Statement For Admission to the Master of Sports Science Degree

Numerical Methods with Excel/VBA:

CHAPTER 15 Capital Structure: Basic Concepts

We rst consider the game from the player's point of view: Suppose you have picked a number and placed your bet. The probability of winning is

COMSC 100 Programming Exercises, For SP15

Task 4 Extended writing: The advantages and disadvantages of using mobile phones

VISUAL ALGEBRA FOR COLLEGE STUDENTS. Laurie J. Burton Western Oregon University

Introduction to the course, Eclipse and Python

NLP Lab Session Week 3 Bigram Frequencies and Mutual Information Scores in NLTK September 16, 2015

Logic Appendix. Section 1 Truth Tables CONJUNCTION EXAMPLE 1

4.2 Euclid s Classification of Pythagorean Triples

Deterministic Discrete Modeling

Lesson 3: Constructing Circle Graphs. Selected Content Standards. Translating Content Standards into Instruction

MATH 2 Course Syllabus Spring Semester 2007 Instructor: Brian Rodas

Power Electronics. Prof. K. Gopakumar. Centre for Electronics Design and Technology. Indian Institute of Science, Bangalore.

requests_toolbelt Documentation

Orthogonal Projections

FIN Chapter 6. Annuities. Liuren Wu

Notes for Lecture 2 (February 7)

Lecture 8. Confidence intervals and the central limit theorem

Department of Mathematics Texas A&M University-Kingsville

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

MBA Quantitative Methods PC-Exercises Introductory Examples

Transcription:

Homework 1 Comp 140 Fall 2008

The Webster problem The devil made a proposition to Daniel Webster. The devil proposed paying Daniel for services in the following way:"on the first day, I will pay you $1,000 early in the morning. At the end of the day, you must pay me a commission of $100. At the end of the day, we will both determine your next day's salary and my commission. I will double what you have earned at the end of the day, but you must double the amount that you pay me. Will you work for me for a month?" 2

Variation #1 Suppose Webster wants out of the deal on the day before his salary for that day is less than zero. Compute when Webster should quit working for the devil, and can make the following counteroffer: I will take your starting salary of $1000 and give you a starting commission of $100, and follow your other rules, but I will quit on the t-th day. Now make the decision based on his net take (sum of takes up to day t) 3

Homework problem 1a Identify the key abstraction choices, then write the recipe for Variation 1 using mathematics, and translate it into a Python program after choosing an appropriate computational mapping. Run the Python program interactively, and report the answer. Try the second decision rule (quitting based on net take) and see if the answer is different. Use websterone.py and webstertwo.py available from Owlspace and the Sharepoint site. 4

Variation #2 Suppose Webster wants out of the deal before his salary on a day is less than zero. Calculate the starting salary that Webster should negotiate so he can work for the devil according to the devil s terms in the original problem (the full 30 days). Identify the abstraction choices, then write the recipe in mathematics, and finally in Python. Run your Python program and report the answer. Replace salary on specific day by net take up that day in the decision rule above, and see if your answer is different. 5

Homework problem 1b Identify the key abstraction choices, then write the recipe for Variation 2 using mathematics, and translate it into a Python program after choosing an appropriate computational mapping. Run the Python program interactively, and report the answer. Try the second decision rule (quitting based on net take) and see if the answer is different. 6

A useful construct A function that takes a start salary as input and computes Webster s salary on the 30 th day s webstertake Salary on the 30 th day 7

Functions in Python def double(x): return 2*x double(2) double(double(2)) double( hello ) 8

webstertake function def webstertake(s): ''' Calculates Webster s salary on the 31st day starting with a salary of s on day 0 and devil's commission that starts at 100 and doubles each day ''' w = [s] d = [100] for t in range(30): w.append(2*(w[t]-d[t])) d.append(2*d[t]) return w[30] 9

Starter hint for Problem 1b Armed with function, webstertake, how can you find the start salary s for which Webster s salary on the 31 st day is exactly zero? 10

Problem 2 Read the essay on Computational Thinking by J. Wing. Contrast Wing s views on computer science with what your view of computer science was before you read the article, and before the first comp140 lecture. 11

Format of answer Structure Paragraph 1: What I thought computer science was about (e.g., in high school), and why you held that view (point to supporting evidence) Paragraph 2: My new view of computer science (after lecture 0 of comp140 and Wing s article). Identify the most compelling argument in Wing s article for you. Paragraph 3: If your old and new views are the same, explain why, with supporting arguments and evidence. 12