Assignment 1.1
Assignment 1.1
Calculator
Objectives
You will be analysing and writing a simple triangle calculator. You will work individually and
demonstrate:
Analysis and understanding of trigonometric formulae
Ability to write Python code that gets user input, calls a function to perform the computation,
and display the results
Understanding of appropriate data types
Use of rounding, f-strings, and math module
Requirements
DO NOT START CODING UNTIL YOU’VE READ THROUGH THE REST OF
THE INSTRUCTIONS.
In this assignment, we will be writing an application that gets the values of
the lengths of 3 sides of a triangle (referred to as a, b,and c) from the
user, and displays the three angles A, B, and C that define that triangle.
Recall that all acute triangle problems with 3 known sides can be solved to
find the 3 angles, using the Law of Cosines.
Your code will:
Define the function calcAngle that will calculate and return the angle R
in degrees, given sides r, s, and t. Make sure you write the docstring
for your function
Define the function findAngles which in turn invokes the calcAngle
function three times, and then display the angles (in degrees), using f-
strings to display the appropriate number of significant figures. Make
sure you write the docstring.
Hint: the g (general format spefier takes the precision after the ., and
{} are used around variables. So for example with variables A and
sigfig:
print(f'the angle is {A:.{sigfig}g}’)
Ask the user for triangle side lengths a, b and c and the number of
significant figures, and invoke findAngles.
Before coding, ask yourself what are the parameters passed to the function,
and what it returns, if anything. We strongly recommend you write the
docstring before starting to code.
Use Visual Studio Code to write your code. Create a file with the
extension .py and write your code there. When you complete the
assignment, submit that file on Lea.
For your calculations, you need a few functions in math library, specifically
the following functions: