0% found this document useful (0 votes)
25 views

Assignment 1.1

where
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Assignment 1.1

where
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 1: Acute Triangle

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

Deliverables (% of assignment grade)


A. Before the lab period, complete and submit the pre-lab (on Moodle) before commencing the
assignment. (10%)
B. Before leaving the lab, you must submit the work you have done, whether it is complete or not.
You must answer the End-of-Lab Check-in on Moodle. Your code is worth up to 80% of the
grade
C. After you have submitted the completed code, fill in the assignment Reflection on Moodle (10%)
(next week on Tuesday)
D. If your instructor detects a significant discrepancy between what was submitted at the end of
the lab period vs what was submitted after working from home, they may ask the student
probing questions to determine if they are indeed the author of the code. Academic honesty
rules will apply as per ISEP.

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:

math.sqrt(x), which calculates the square root of a number

math.cos(x), which returns the cosine

math.acos(x), which returns the reverse of a cosine


math.degrees(x), which converts radian to degrees

This is the link to Mathematical functions in Python:

math — Mathematical functions — Python 3.12.6 documentation

You might also like