Due 11:59pm Tuesday night, September 16

Run `update21`, if you haven't already, to create the
`cs21/labs/02` directory. `handin21`
looks for your lab 2 assignments in the `cs21/labs/02` directory, so
make sure you create your python programs in there:

$ cd cs21/labs/02 $ vi line.py

Your programs are graded on both correctness and style. Please review
the comments regarding programming style on the main page.

Computing distance and slope

Write a program, in a file named `line.py`, that asks the user to enter
the value of two points in
the Cartesian plane and then computes the slope of the line defined by those
points and the distance between the points (formulas are on p.73, exercises
6 and 7).

Here is what two runs of your program might look like:

$ python line.py Given two points, (x1, y1) and (x2, y2), this program computes the distance between them and the slope of the line they define Enter the x coordinate of the first point: 1 Enter the y coordinate of the first point: 1 Enter the x coordinate of the second point: 4 Enter the y coordinate of the second point: 5 The distance between (1,1) and (4,5) is 5.00 The slope of the line they define is 1.33 $ python line.py Given two points, (x1, y1) and (x2, y2), this program computes the distance between them and the slope of the line they define Enter the x coordinate of the first point: 6 Enter the y coordinate of the first point: 12 Enter the x coordinate of the second point: 10 Enter the y coordinate of the second point: 30 The distance between (6,12) and (10,30) is 18.44 The slope of the line they define is 4.50

Try using string formating to limit the number of places printed beyond the decimal point.

To use math library functions, remember to add this to the top of your program:

from math import *

Zeno's Dichotomy Paradox

Zeno, a 5th century BC Greek philosopher wrote 40 "paradoxes of plurality", attempting to show that ontological pluralism - a belief in the existence of many things rather than only one - leads to absurd conclusions" [from the Stanford Encyclopedia of Philosophy]

Zeno's Dichotomy Paradox is a pardox about continuous motion: before one can reach his/her destination he/she must first arrive at the half-way point, but before he/she can reach the half-way point, he/she must first arrive at the half-way point of the half-way point, and so on. Since this process continues forever, one can never reach his/her destination.

Zeno's paradox can be written mathematically as the sum of the following infinite series:

1 1 1 1 1 -- + -- + -- + -- + -- + ... 2 4 8 16 32

Since today we know that infinite series can have finite sums, we may not find Zeno's paradox so paradoxical.

Write a program, in a file named `zeno.py`, that computes the sum of
the first n terms in the above series, given a value for n that is
entered by the user. For example, a couple runs of your program may
look like this:

$ python zeno.py This program computes the sum of the first n terms of the series based on Zeno's Dichotomy paradox Enter a value a value for n: 3 the sum of the first 3 terms is 0.875 $ python zeno.py This program computes the sum of the first n terms of the series based on Zeno's Dichotomy paradox Enter a value a value for n: 20 the sum of the first 20 terms is 0.999999046326

Acronyms

Write a program in a file named `acronyms.py`, that prompts the user to
enter a phrase, and then converts the phrase to it acronym. Here are a
couple runs of what your program might look like:

$ python acronyms.py This program creates acronyms from a phrase. Enter a phrase: the World needs one more acronym The acronym of "the World needs one more acronym" is: TWNOMA $ python acronyms.py This program creates acronyms from a phrase. Enter a phrase: to be or not to be The acronym of "to be or not to be" is: TBONTB

Submit

Once you are satisfied with your programs, hand them in by typing
**handin21** at the unix prompt.
You may run **handin21** as many times as you like, and only the
most recent submission will be recorded. This is useful if you realize
after handing in some programs that you'd like to make a few more
changes to them.