Homework Assignment for Comp 140: Webster Problem and Computational Thinking - Prof. Devik, Assignments of Computer Science

A homework assignment for a university course named comp 140, which was given in the fall semester of 2008. The assignment includes several problem variations based on the webster problem, where daniel webster has to decide whether to continue working for the devil based on certain conditions. Students are required to write recipes using mathematics, translate them into python programs, and run the programs to find the answers. Additionally, students are asked to read an essay on computational thinking by j. Wing and contrast their views on computer science before and after the assignment and the lecture.

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-owy-1
koofers-user-owy-1 🇺🇸

3

(1)

9 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework 1
Comp 140
Fall 2008
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Homework Assignment for Comp 140: Webster Problem and Computational Thinking - Prof. Devik and more Assignments Computer Science in PDF only on Docsity!

  • Homework
    • Comp
    • Fall

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?"

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.

Variation

 (^) 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.

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

Functions in Python

def double(x):

return 2*x

double(2)

double(double(2))

double(‘hello’)

Starter hint for Problem 1b

Armed with function, websterTake,

how can you find the start salary s for

which Webster’s salary on the 3 1

st

day

is exactly zero?

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.