Hidden WordScanner
Private scans · No account required

DuckieDai Heron's Formula

Calculate a triangle's area, perimeter, and semiperimeter from three side lengths.

geometry · MIT License

Overview

Calculate a triangle's area, perimeter, and semiperimeter from three side lengths.

  • Tested on a TI calculator
  • Downloaded 46 times
  • Version 1.0.0
  • 2772 bytes
  • Uses math

Before you run it

  • TI-84 Plus CE Python · tested on OS 5.8.3, Python App 5.8.3.0048
  • TI Connect CE .py conversion to a Python AppVar in RAM; owner physically verified the supplied program.
  • The three values form a nondegenerate triangle.
  • Each side must be positive and the triangle inequality must hold.
  • Invalid side sets are rejected.

Try the DuckieDai calculator screen

This browser preview calculates a valid triangle's area from its three sides.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

Learn the math

How Heron's formula works

The idea

Heron's formula finds the area of a triangle from its three side lengths alone. You do not need a height or any angles.

It works through the semiperimeter, which is half the distance around the triangle.

The formula

s = (a + b + c)/2

A = sqrt(s(s-a)(s-b)(s-c))

a, b, c
the three side lengths
s
semiperimeter
A
area

Using the program

Worked example

A triangle has sides 3, 4, and 5. Enter 3, 4, and 5.

s = 6 A = sqrt(6 x 3 x 2 x 1)

The program shows Perimeter = 12.0, Semiperimeter = 6.0, and Area = 6.0 square units.

Tips and common mistakes

Where this comes up

It is taught in geometry and trigonometry as a way to find area without a height, and it is handy in surveying-style problems where only distances are measured.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. """DuckieDai Heron's Formula for TI-84 Plus CE Python."""
  2. from math import sqrt
  3. def duckiedai_intro(program_name, wait=True):
  4. """Show the reusable DuckieDai program opening."""
  5. title = program_name[:16]
  6. empty = 16 - len(title)
  7. left = empty // 2
  8. right = empty - left
  9. print("+----------------------+")
  10. print("| " + " " * left + title + " " * right + " |")
  11. print("| |")
  12. print("| __ |")
  13. print("| ___(o )> quack! |")
  14. print("| \\ <_. ) |")
  15. print("| `---' |")
  16. print("| by DuckieDai |")
  17. print("+----------------------+")
  18. print("Loading...")
  19. if wait:
  20. input("Press enter to start ")
  21. print("\n" * 6)
  22. def positive_number(prompt):
  23. """Require a number greater than zero."""
  24. while True:
  25. try:
  26. value = float(input(prompt))
  27. if value > 0 and value < 1e100:
  28. return value
  29. except ValueError:
  30. pass
  31. print("Enter a number above 0.")
  32. def valid_triangle(a, b, c):
  33. """Check the triangle inequality."""
  34. return (
  35. a + b > c and
  36. a + c > b and
  37. b + c > a
  38. )
  39. def heron_area(a, b, c):
  40. """Calculate triangle area using Heron's Formula."""
  41. s = (a + b + c) / 2
  42. area = sqrt(
  43. s *
  44. (s - a) *
  45. (s - b) *
  46. (s - c)
  47. )
  48. return s, area
  49. def main():
  50. duckiedai_intro("HERONS FORMULA")
  51. print("HERON'S FORMULA")
  52. print("TRIANGLE AREA")
  53. print()
  54. print("A = sqrt(")
  55. print("s(s-a)(s-b)(s-c))")
  56. print()
  57. print("s = (a+b+c)/2")
  58. print()
  59. a = positive_number("Side a: ")
  60. b = positive_number("Side b: ")
  61. c = positive_number("Side c: ")
  62. print()
  63. if not valid_triangle(a, b, c):
  64. print("INVALID TRIANGLE")
  65. print()
  66. print("These side lengths")
  67. print("cannot form a")
  68. print("triangle.")
  69. else:
  70. s, area = heron_area(a, b, c)
  71. perimeter = a + b + c
  72. print("Using:")
  73. print("s = (a+b+c)/2")
  74. print()
  75. print("s = " + str(s))
  76. print()
  77. print("A = sqrt(")
  78. print("s(s-a)(s-b)(s-c))")
  79. print()
  80. print("RESULTS")
  81. print()
  82. print("Perimeter =")
  83. print(str(perimeter))
  84. print()
  85. print("Semiperimeter =")
  86. print(str(s))
  87. print()
  88. print("Area =")
  89. print(str(area))
  90. print("square units")
  91. print()
  92. print("DuckieDai says: done!")
  93. # TI-Python imports the selected AppVar rather than
  94. # setting __name__ to main.
  95. main()
Filename
HERON.py
Size
2772 bytes
SHA-256
f3100020895192b51d053c34e245d65eb4b1f606ff63c263daecc839a9ddffc3

Usage

Inputs

  • Three positive side lengths

Outputs

  • Triangle area, perimeter, and semiperimeter

Units: Use one consistent length unit; area uses that unit squared.

Assumptions and limitations

Assumptions

  • The three values form a nondegenerate triangle.

Constraints

  • Each side must be positive and the triangle inequality must hold.

Known failures

  • Invalid side sets are rejected.
  • Inconsistent units produce an incorrect result.

Compatibility and review

Review status
Tested on a TI calculator
Tested on
TI-84 Plus CE Python; OS 5.8.3; Python App 5.8.3.0048; exact source owner-tested through TI Connect CE
What happened
Owner confirmed the supplied Heron's formula program runs on the physical calculator.
Dependencies
math
Suggested calculator name
HERON — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Transfer and launch

Download the .py file, send it to your calculator with TI Connect CE as HERON or another name, then open the Python App and try the worked example on this page first.

Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.

Version history

Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.