CPSC120A
Fundamentals of Computer Science I

Lab 3

Naming

Use the command line to create a new directory called lab3 in your labs directory. Make sure all of the .py files that you create for this activity are in that directory.

Distance

In Emacs, create a Python program in a file called distance.py. The program should print the distance between the points (1,2) and (3,2). The distance between two points can be calculated using the following formula:

d=(x2x1)2+(y2y1)2

Where d is the distance between the points (x1,y1) and (x2,y2). The program should use meaningful names for values and simple statements to make the program more readable. The output should be nicely formatted and labeled.

Oil Drum Volume

In Emacs, create a Python program in a file called oil_drum.py. The program should print the number of gallons in an oil drum. An oil drum is 33.5 inches tall with a radius of 11.25 inches. The volume of a cylinder can be computed using the equation:

v=ah
a=πr2

Where v is the volume of a cylinder, a is the area of the base of the cylinder, h is the height of thy cylinder, and r is the radius of the cylinder. One gallon is 231 cubic inches. The program should use meaningful names for values and simple statements to make the program more readable. The output should be nicely formatted and labeled.

Boring Origami

A single sheet of paper is 0.004 inches thick. If you fold the paper in half, the two halves of the sheet of paper are together 0.008 inches thick. If you fold the paper in half again the four quarters are together 0.016 inches thick. How thick would the paper be if you folded it in half 10 times?

In Emacs, create a Python program in a file called origami.py. The program should print how thick a piece of paper would be if you folded it in half 10 times. The program should use meaningful names for values and simple statements to make the program more readable. The output should be nicely formatted and labeled.

Submission

Please show your source code and run your programs for the instructor or lab assistant. Only a programs that have perfect style and flawless functionality will be accepted as complete.