CSc 110: Math

This assignment should be written in the python programming language. You should only use python features that we have discussed up to this point. If you have questions about whether or not a particular feature can/should be used, ask the instructors! You may use any python version 3.0 or newer.

All of your programming should be well-formatted and easy for the graders to read and comprehend. Each program file should have a header comment at the top that has the following format:

#
# Author: Student Name
# Description:
#    A short description of what this program does!
# 

If any part of your scripts are particularly complex, you should put documentation comments above those lines of code.

Math (X points)

In this assignment, you will write multiple small programs that compute various mathematical formulas.

Volume

Write a python program and name it volume.py. This program will be used to compute the volume of a cube. Recall that the volume of a cube is the width x height x length.

At the beginning of your program, you should ask the user of your program (you!) for three numeric values.

Specifically, you should ask for the width, height, and length of a cube. When run, the part of the program that requests these inputs should look like this:

Enter width: X
Enter height: Y
Enter length: Z

The user will be able to put any positive integer number for X, Y, and Z.

Next, you must write a function named volume that computes the volume of a cube given the dimensions stores in these variables. It should then print out:

The volume of a cube with width X, height Y, and length Z is A

(But you should replace X, Y, Z, and A with the width, height, length, and computed result, respectively).

Pythagorean

Write a python program and name it pythagorean.py. This program will be used to compute the length of the hypotenuse of a right triangle, given the length of the other two sides. Recall the Pythagorean theorem, which states that:

a^2 + b^2 = c^2

For right triangles.

At the beginning of your program, you should ask the user of your program (you!) for two numeric values.

Specifically, you should ask for the lengths of the two sides of the triangle that make up the right angle. When run, the part of the program that requests these inputs should look like this:

Enter first side: X
Enter second side: Y

Again, the user will be able to put any positive integer number for X and Y.

After declaring these variables, you must write a function named print_hyp_length that computes the length of the hypotenuse, given the lengths of these two other sides. It should then print out:

The hypotenuse of a right triangle is length X when the other two sides are of length Y and Z

(But you should replace X, Y, and Z with the actual lengths).

Distance Between Two Points

Write a python program named distance.py. This program will be used to compute the distance between two points on the Cartesian plane. Recall the distance formula (based on the Pythagorean theorem), which states that:

Using this formula, we can find the distance between the x,y point (x1, y1) and (x2 y2) on the Cartesian plane.

At the beginning of your program, you should ask the user of your program (you!) for four numeric values.. The four values are:

When run, this should look like:

Enter x1: ?
Enter y1: ?
Enter x2: ?
Enter y2: ?

The user will be able to put any integer for each value. After declaring these variables, you must compute the distance between the coordinates and print out the result. It should then print out:

The distance between (x1, y1) and (x2, y2) is A.

(But you should replace x1, y1, x2, y2 and A with the actual computed lengths).

Misc

Make sure that for each of your programs, all of the code is structured in functions. Each of the programs you submit should have at least two functions (and one should be main()). Also, don’t forget to call main.

Submission and grading

This was assigned on 6/18/2017. It is due on Thursday (6/22/2016) at 6:00pm.

You should submit all python files into the dropbox: volume.py, pythagorean.py, distance.py Submit these files to the associated D2L dropbox. Following these turn-in and naming instructions closely is very important, because our grading scripts will depend on some of the details. You may lose points if these instructions are not followed precisely!