geometry · MIT License
Overview
Calculate a rectangle's area while showing the formula, accepting a user-chosen length unit, and labelling the squared result.
- Tested on a TI calculator
- Downloaded 39 times
- Version 1.0.0
- 2167 bytes
- No imports
Tried it? Did this program work on your calculator?
Before you run it
- TI-84 Plus CE Python · tested on OS 5.8.3, Python App 5.8.3.0048
- Sent through TI Connect CE to the Python App; DuckieDai named the calculator copy TEST
- Width and height describe a rectangle and use the same unit.
- Each dimension must be greater than zero and below 1e100.
- The calculated area must be below 1e200.
Try the DuckieDai calculator screen
See the duck opening, enter a unit and dimensions, and follow the prompts through to the area result.
TI-84 Plus CE Python · screen preview
Learn the math
How the area of a rectangle works
The idea
Area measures how much flat space a shape covers. For a rectangle it is the width multiplied by the height, and the answer is in square units.
The formula
A = width x height
A- area, in square units
width, height- the two side lengths, in the same unit
Using the program
- Type the unit you are using, such as cm, m, or in.
- Enter the width and the height. The program labels the answer with your unit squared.
Worked example
A rectangle is 4 cm wide and 2.5 cm tall. Enter cm, then 4 and 2.5.
A = 4.0 x 2.5
The program shows Area = 10.0 cm^2.
Tips and common mistakes
- Both sides must be in the same unit before you multiply.
- Area is in square units; perimeter is not. They answer different questions.
- This is the simplest program in the library and a good first one to transfer and try.
Where this comes up
Area of a rectangle is the first area formula taught and the basis for every other one. Here it mainly serves as a simple first program to transfer and run.
Read the step-by-step browser preview guide to try a sample and understand what the preview does and does not test.
Exact reviewed bytes
Source code
"""DuckieDai Rectangle Area for TI-84 Plus CE Python."""def duckiedai_intro(program_name, wait=True):"""Show the small, reusable DuckieDai program opening."""title = program_name[:16]empty = 16 - len(title)left = empty // 2right = empty - leftprint("+----------------------+")print("| " + " " * left + title + " " * right + " |")print("| |")print("| __ |")print("| ___(o )> quack! |")print("| \\ <_. ) |")print("| `---' |")print("| by DuckieDai |")print("+----------------------+")print("Loading...")if wait:input("Press enter to start ")print("\n" * 6)def positive_number(prompt):"""Ask until the user supplies a positive, finite number."""while True:try:value = float(input(prompt))if is_positive_finite(value):return valueexcept ValueError:passprint("Enter a number above 0.")def is_positive_finite(value):"""Use a practical calculator range without math.isfinite."""return value > 0 and value < 1e100def rectangle_area(width, height):"""Return area for two positive, finite dimensions."""if not is_positive_finite(width) or not is_positive_finite(height):raise ValueError("dimensions must be positive and finite")area = width * heightif area >= 1e200:raise ValueError("area is too large")return areadef main():duckiedai_intro("RECTANGLE AREA")print("RECTANGLE AREA")print("Formula: A = width x height")print()unit = input("Length unit (cm, m, in): ")if not unit:unit = "units"width = positive_number("Width in " + unit + ": ")height = positive_number("Height in " + unit + ": ")area = rectangle_area(width, height)print()print("A = " + str(width) + " x " + str(height))print("Area = " + str(area) + " " + unit + "^2")print()print("DuckieDai says: done!")# TI-Python imports the selected AppVar rather than setting __name__ to main.main()
- Filename
rectangle_area.py- Size
- 2167 bytes
- SHA-256
5291290b23032d479d34f740ca41a5a13f96a036636544784054aadfa6478b32
Usage
Inputs
- Length unit: a short label such as cm, m, or in; blank becomes units
- Width: positive number below 1e100 in the chosen unit
- Height: positive number below 1e100 in the chosen unit
Outputs
- Area: width multiplied by height, labelled with the chosen unit squared
Units: Width and height must share one length unit; output uses that unit squared.
Assumptions and limitations
Assumptions
- Width and height describe a rectangle and use the same unit.
Constraints
- Each dimension must be greater than zero and below 1e100.
- The calculated area must be below 1e200.
Known failures
- Non-numeric, zero, negative, or excessively large dimensions are rejected and requested again.
- Very long custom unit labels may wrap on the calculator display.
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; transferred through TI Connect CE as TEST
- What happened
- The duck opening appeared, and the calculator accepted a unit and rectangle dimensions before displaying the labelled area answer.
- Dependencies
- No imports
- Suggested calculator name
RECTAREA— you can give it another valid, unique name when you transfer it- Desktop test cases
- 5 cases
The desktop tests cover calculations and error handling. The calculator review above records what was actually checked on the device.
Transfer and launch
Download the .py file, send it to your calculator with TI Connect CE as RECTAREA 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
- 1.0.0 — current version, published . Download this reviewed version
Related learning
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.