A simple package to calculate area and perimeter of 2d shapes.
Project description
Arnold Package
This Python project provides classes to represent and calculate properties for various geometric shapes: Square, Rectangle, Circle, and Triangle. Each class supports methods to calculate the area and perimeter.
Classes
Square
-
Constructor:
Square(length: float)
- Parameters:
length
: Length of the square's side (positive integer or float).
- Parameters:
-
Methods:
area()
: Returns the area of the square.perimeter()
: Returns the perimeter of the square.
Rectangle
-
Constructor:
Rectangle(width: float, height: float)
- Parameters:
width
: Width of the rectangle (positive integer or float).height
: Height of the rectangle (positive integer or float).
- Parameters:
-
Methods:
area()
: Returns the area of the rectangle.perimeter()
: Returns the perimeter of the rectangle.
Circle
-
Constructor:
Circle(radius: float)
- Parameters:
radius
: Radius of the circle (positive integer or float).
- Parameters:
-
Methods:
area()
: Returns the area of the circle.perimeter()
: Returns the circumference of the circle.
Triangle
-
Constructor:
Triangle(base: float = None, height: float = None, side1: float = None, side2: float = None, side3: float = None)
- Parameters:
base
: Base of the triangle (positive integer or float).height
: Height of the triangle (positive integer or float).side1
: Length of the first side (positive integer or float).side2
: Length of the second side (positive integer or float).side3
: Length of the third side (positive integer or float).
- Parameters:
-
Methods:
area()
: Returns the area of the triangle (uses either base and height or all three sides).perimeter()
: Returns the perimeter of the triangle.
Usage Example
Here’s a simple example of how to use the classes:
from arnold import Square, Rectangle, Circle, Triangle
# Create a Square object
square = Square(4)
print(f"Square Area: {square.area()}")
print(f"Square Perimeter: {square.perimeter()}")
# Create a Rectangle object
rectangle = Rectangle(3, 5)
print(f"Rectangle Area: {rectangle.area()}")
print(f"Rectangle Perimeter: {rectangle.perimeter()}")
# Create a Circle object
circle = Circle(2)
print(f"Circle Area: {circle.area()}")
print(f"Circle Perimeter: {circle.perimeter()}")
# Create a Triangle object
triangle = Triangle(base=3, height=4, side1=3, side2=4, side3=5)
print(f"Triangle Area: {triangle.area()}")
print(f"Triangle Perimeter: {triangle.perimeter()}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file arnold_bhadauria-0.1.0.tar.gz
.
File metadata
- Download URL: arnold_bhadauria-0.1.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bb7392bc4fcee795e520ab0c670604b35fc1877d64f46109017a5ac0dc65bb6 |
|
MD5 | 3f4202a4d67efcb122b549a51d41b7c8 |
|
BLAKE2b-256 | b683b9cfa4628538e7c12eb2168a41fee2e64df10256c1978f40b77ad31c2b41 |
File details
Details for the file arnold_bhadauria-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: arnold_bhadauria-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 793feb0fda6038b871e9cf3b61286d6c82263f04ac0b7ac884540a75f8001705 |
|
MD5 | 9f2309e06528e02ac99c4c6f4616e601 |
|
BLAKE2b-256 | 68c963beef13eb2268116d1e6a604e4cfc7605f283f9482d01aa5e498aa152da |