Skip to main content

Finds the remaining sides and angles of a triangle when given enough of the sides and/or angles. Includes a command line exerciser, formatting tools, and a test suite.

Project description

Mostly you will use:

err_msg, a, b, c, A, B, C = complete_the_triangle(a, b, c, A, B, C)

This is the main routine in the plane_triangles.py module. Its input parameters default to None.

It solves (if possible) for the missing sides and/or angles in the parameter list.

If two solutions are possible, it will indicate this by a return value in err_msg that starts with “Other”. The first answer should be used, then a request made for the return of the second by repeating the original call with the ssa_flag set to 'other', i.e.

err_msg, a, b, c, A, B, C = complete_the_triangle(a, b, c, A, B, C, ssa_flag='other')

All of the exported functions (it’s ok to use plane_triangles import *) have help text included. So you can get help with the usual help(complete_the_triangle) method. There are a number of formatting routines for converting angles to various forms (radians, degrees, degrees and minutes, degrees minutes seconds) with a specified precision.

The module (plane_triangles_tests.py) contains a set of tests. It uses assert statements to detect errors. Importing the module will run the tests. All is well when no assert throws an exception.

There is an interactive test/excercise program that can be invoked by importing and executing run_ui() from the module excerciser.py. It starts with a prompt that allow one to set the desired format for the display of angles (radians, degrees, degrees and minutes, degrees and minutes and seconds).

The next two prompts allow the precision (number of digits to right of decimal point) for angles and lengths to be specified.

A loop is then entered that prompts for the sides and angles to be used. Just press enter to indicate that a value will not be provided (i.e., is to be calculated).

If all six parameters are left empty, the loop terminates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

planetriangles-1.0-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page