Hidden WordScanner
Private scans · No account required

DuckieDai Pick's Theorem

Solve a lattice polygon's area, interior-point count, or boundary-point count with Pick's theorem.

geometry · MIT License

Overview

Solve a lattice polygon's area, interior-point count, or boundary-point count with Pick's theorem.

  • Tested on a TI calculator
  • Downloaded 45 times
  • Version 1.0.0
  • 5044 bytes
  • No imports

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 polygon is a lattice polygon and Pick's theorem applies.
  • The TI program validates nonnegative or positive whole-number point counts.
  • Non-lattice or inapplicable polygons produce an incorrect interpretation.

Try the DuckieDai calculator screen

This browser preview calculates area from interior and boundary point counts. The TI program also solves the inverse counts.

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 Pick's theorem works

The idea

If a polygon's corners all sit on grid points, you can find its area just by counting dots: the grid points inside it and the grid points on its edge.

The formula

A = i + b/2 - 1

A
area in square grid units
i
grid points strictly inside the polygon
b
grid points on the boundary, corners included

Using the program

Worked example

A polygon on a grid has 4 points inside and 6 on its boundary. Choose 1 and enter 4 and 6.

A = 4 + 6/2 - 1

The program shows Area = 6.0 square units.

Tips and common mistakes

Where this comes up

It appears in geometry enrichment units and math competitions, and it is a quick check for area problems drawn on grid paper.

Exact reviewed bytes

Source code

Download .py

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

  1. """DuckieDai Pick's Theorem for TI-84 Plus CE Python."""
  2. def duckiedai_intro(program_name, wait=True):
  3. """Show the reusable DuckieDai program opening."""
  4. title = program_name[:16]
  5. empty = 16 - len(title)
  6. left = empty // 2
  7. right = empty - left
  8. print("+----------------------+")
  9. print("| " + " " * left + title + " " * right + " |")
  10. print("| |")
  11. print("| __ |")
  12. print("| ___(o )> quack! |")
  13. print("| \\ <_. ) |")
  14. print("| `---' |")
  15. print("| by DuckieDai |")
  16. print("+----------------------+")
  17. print("Loading...")
  18. if wait:
  19. input("Press enter to start ")
  20. print("\n" * 6)
  21. def whole_number(prompt):
  22. """Require a nonnegative whole number."""
  23. while True:
  24. try:
  25. value = int(input(prompt))
  26. if value >= 0:
  27. return value
  28. except ValueError:
  29. pass
  30. print("Enter a whole number")
  31. print("0 or greater.")
  32. def positive_whole(prompt):
  33. """Require a positive whole number."""
  34. while True:
  35. try:
  36. value = int(input(prompt))
  37. if value > 0:
  38. return value
  39. except ValueError:
  40. pass
  41. print("Enter a whole number")
  42. print("above 0.")
  43. def positive_number(prompt):
  44. """Require a positive number."""
  45. while True:
  46. try:
  47. value = float(input(prompt))
  48. if value > 0 and value < 1e100:
  49. return value
  50. except ValueError:
  51. pass
  52. print("Enter a number above 0.")
  53. def main():
  54. duckiedai_intro("PICKS THEOREM")
  55. print("PICK'S THEOREM")
  56. print()
  57. print("A = i + b/2 - 1")
  58. print()
  59. print("i = interior points")
  60. print("b = boundary points")
  61. print()
  62. print("What do you need?")
  63. print()
  64. print("1. Area")
  65. print("2. Interior points")
  66. print("3. Boundary points")
  67. print()
  68. choice = input("Choose 1-3: ")
  69. print()
  70. # ==========================================
  71. # 1. SOLVE AREA
  72. #
  73. # A = i + b/2 - 1
  74. # ==========================================
  75. if choice == "1":
  76. i = whole_number(
  77. "Interior points: "
  78. )
  79. b = positive_whole(
  80. "Boundary points: "
  81. )
  82. area = (
  83. i +
  84. b / 2 -
  85. 1
  86. )
  87. print()
  88. print("Using:")
  89. print("A = i + b/2 - 1")
  90. print()
  91. print("A = " + str(i))
  92. print("+ " + str(b) + "/2")
  93. print("- 1")
  94. print()
  95. print("ANSWER")
  96. print("Area = " + str(area))
  97. print("square units")
  98. # ==========================================
  99. # 2. SOLVE INTERIOR POINTS
  100. #
  101. # i = A - b/2 + 1
  102. # ==========================================
  103. elif choice == "2":
  104. area = positive_number(
  105. "Area: "
  106. )
  107. b = positive_whole(
  108. "Boundary points: "
  109. )
  110. i = (
  111. area -
  112. b / 2 +
  113. 1
  114. )
  115. print()
  116. print("Using:")
  117. print("A = i + b/2 - 1")
  118. print()
  119. print("Rearranged:")
  120. print("i = A - b/2 + 1")
  121. print()
  122. if i < 0 or i != int(i):
  123. print("INVALID RESULT")
  124. print()
  125. print("Interior points")
  126. print("must be a whole")
  127. print("number.")
  128. print()
  129. print("Check your values.")
  130. else:
  131. i = int(i)
  132. print("ANSWER")
  133. print("Interior points =")
  134. print(str(i))
  135. # ==========================================
  136. # 3. SOLVE BOUNDARY POINTS
  137. #
  138. # b = 2(A - i + 1)
  139. # ==========================================
  140. elif choice == "3":
  141. area = positive_number(
  142. "Area: "
  143. )
  144. i = whole_number(
  145. "Interior points: "
  146. )
  147. b = (
  148. 2 *
  149. (area - i + 1)
  150. )
  151. print()
  152. print("Using:")
  153. print("A = i + b/2 - 1")
  154. print()
  155. print("Rearranged:")
  156. print("b = 2(A-i+1)")
  157. print()
  158. if b <= 0 or b != int(b):
  159. print("INVALID RESULT")
  160. print()
  161. print("Boundary points")
  162. print("must be a positive")
  163. print("whole number.")
  164. print()
  165. print("Check your values.")
  166. else:
  167. b = int(b)
  168. print("ANSWER")
  169. print("Boundary points =")
  170. print(str(b))
  171. else:
  172. print("Invalid choice.")
  173. print()
  174. print("DuckieDai says: done!")
  175. # TI-Python imports the selected AppVar rather than
  176. # setting __name__ to main.
  177. main()
Filename
PICKTHE.py
Size
5044 bytes
SHA-256
1714c126a432524b92b65e5458d8a81699a3015d89d725f9ebc2295a23eca18a

Usage

Inputs

  • Requested unknown: area, interior points, or boundary points
  • Nonnegative interior count and positive boundary count where applicable

Outputs

  • Requested Pick's-theorem quantity or invalid-result warning

Units: Area is in square coordinate units; point counts are whole numbers.

Assumptions and limitations

Assumptions

  • The polygon is a lattice polygon and Pick's theorem applies.

Constraints

  • The TI program validates nonnegative or positive whole-number point counts.

Known failures

  • Non-lattice or inapplicable polygons produce an incorrect interpretation.

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 Pick's theorem program runs on the physical calculator.
Dependencies
No imports
Suggested calculator name
PICKTHE — 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 PICKTHE 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.