Hidden WordScanner
Private scans · No account required

DuckieDai Gravitational Potential Energy

Solve near-Earth gravitational potential energy, mass, or height from PE = m*g*h using g = 9.8 m/s^2.

physics · MIT License

Overview

Solve near-Earth gravitational potential energy, mass, or height from PE = m*g*h using g = 9.8 m/s^2.

  • Tested on a TI calculator
  • Downloaded 39 times
  • Version 1.0.0
  • 3916 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; physically verified one program at a time
  • Gravitational field strength is fixed at 9.8 m/s^2 and height is measured from the chosen zero level.
  • Mass and divisors must be positive; height and potential energy may be zero where offered.
  • The fixed value of g is not suitable when local gravitational field strength differs materially.

Try the DuckieDai calculator screen

Follow the reviewed program's real menu, prompts, validation, calculation, and result flow before downloading.

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 gravitational potential energy works

The idea

Lifting an object stores energy in it. Near the Earth's surface that stored energy is the object's mass times the strength of gravity times its height.

The height is measured from whatever level you call zero, usually the floor or the lowest point in the problem.

The formula

PE = m*g*h

PE
gravitational potential energy in joules (J)
m
mass (kg)
g
9.8 m/s^2, built into the program
h
height above the zero level (m)

Using the program

Worked example

A 2 kg book sits on a shelf 10 m above the floor. Choose 1 and enter mass 2 and height 10.

PE = 2.0 x 9.8 x 10.0

The program shows PE = 196.0 joules.

Tips and common mistakes

Where this comes up

You meet it in the energy unit of high school and college physics, most often in conservation of energy problems: roller coasters, pendulums, falling objects, and anything on a ramp.

Exact reviewed bytes

Source code

Download .py

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

  1. """DuckieDai Potential Energy 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 positive_number(prompt):
  22. """Ask until a positive finite number is entered."""
  23. while True:
  24. try:
  25. value = float(input(prompt))
  26. if value > 0 and value < 1e100:
  27. return value
  28. except ValueError:
  29. pass
  30. print("Enter a number above 0.")
  31. def nonnegative_number(prompt):
  32. """Allow zero or positive values."""
  33. while True:
  34. try:
  35. value = float(input(prompt))
  36. if value >= 0 and value < 1e100:
  37. return value
  38. except ValueError:
  39. pass
  40. print("Enter 0 or greater.")
  41. def show_answer(name, value, unit):
  42. input("Press enter for answer ")
  43. print("\n" * 6)
  44. print("ANSWER")
  45. print(name + " = " + str(value))
  46. print(unit)
  47. def main():
  48. duckiedai_intro("POTENTIAL ENERGY")
  49. g = 9.8
  50. print("GRAVITATIONAL PE")
  51. print()
  52. print("Formula: PE = m*g*h")
  53. print("Using g = 9.8 m/s^2")
  54. input("Press enter for menu ")
  55. print("\n" * 6)
  56. print()
  57. print("What do you need?")
  58. print()
  59. print("1. Potential Energy")
  60. print("2. Mass")
  61. print("3. Height")
  62. print()
  63. choice = input("Choose 1-3: ")
  64. print()
  65. # ==========================================
  66. # 1. SOLVE POTENTIAL ENERGY
  67. # PE = m*g*h
  68. # ==========================================
  69. if choice == "1":
  70. mass = positive_number("Mass (kg): ")
  71. height = nonnegative_number("Height (m): ")
  72. pe = mass * g * height
  73. print()
  74. print("Using:")
  75. print("PE = m*g*h")
  76. print()
  77. print("PE = " + str(mass))
  78. print("x " + str(g))
  79. print("x " + str(height))
  80. show_answer(
  81. "PE",
  82. pe,
  83. "joules"
  84. )
  85. # ==========================================
  86. # 2. SOLVE MASS
  87. # m = PE / (g*h)
  88. # ==========================================
  89. elif choice == "2":
  90. pe = nonnegative_number("PE (J): ")
  91. height = positive_number("Height (m): ")
  92. mass = pe / (g * height)
  93. print()
  94. print("Using:")
  95. print("PE = m*g*h")
  96. print()
  97. print("Rearranged:")
  98. print("m = PE/(g*h)")
  99. show_answer(
  100. "m",
  101. mass,
  102. "kg"
  103. )
  104. # ==========================================
  105. # 3. SOLVE HEIGHT
  106. # h = PE / (m*g)
  107. # ==========================================
  108. elif choice == "3":
  109. pe = nonnegative_number("PE (J): ")
  110. mass = positive_number("Mass (kg): ")
  111. height = pe / (mass * g)
  112. print()
  113. print("Using:")
  114. print("PE = m*g*h")
  115. print()
  116. print("Rearranged:")
  117. print("h = PE/(m*g)")
  118. show_answer(
  119. "h",
  120. height,
  121. "meters"
  122. )
  123. else:
  124. print("Invalid choice.")
  125. print()
  126. print("DuckieDai says: done!")
  127. # TI-Python imports the selected AppVar rather than
  128. # setting __name__ to main.
  129. main()
Filename
GRAVPE.py
Size
3916 bytes
SHA-256
ae1c282439e58780c9af76733d080f0e862b09e898755dfb0311fd3022518ba6

Usage

Inputs

  • Requested unknown: potential energy, mass, or height
  • Two known values using kilograms, metres, and joules

Outputs

  • Requested quantity using PE = m*g*h

Units: Mass uses kilograms, height uses metres, and energy uses joules.

Assumptions and limitations

Assumptions

  • Gravitational field strength is fixed at 9.8 m/s^2 and height is measured from the chosen zero level.

Constraints

  • Mass and divisors must be positive; height and potential energy may be zero where offered.

Known failures

  • The fixed value of g is not suitable when local gravitational field strength differs materially.

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 paginated .py transferred through TI Connect CE into RAM and tested individually
What happened
Passed: branded intro, paginated potential energy menu, calculation workflow, and answer screen ran on the physical calculator
Dependencies
No imports
Suggested calculator name
GRAVPE — 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 GRAVPE 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.