Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions maths/volume_of_cylinder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import math


def volume_of_cylinder(radius: float, height: float) -> float:
"""
Calculate the volume of a cylinder.
Formula: pi * radius^2 * height
Examples:
>>> volume_of_cylinder(3.0, 5.0)
141.37
>>> volume_of_cylinder(2.5, 4.0)
78.54
>>> volume_of_cylinder(0.0, 5.0)
0.0
"""
if radius < 0 or height < 0:
raise ValueError("Radius and height cannot be negative")
volume = math.pi * (radius**2) * height
return round(volume, 2)


if __name__ == "__main__":
import doctest

doctest.testmod()
4 changes: 2 additions & 2 deletions maths/zellers_congruence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
import datetime
import datetime as dt


def zeller(date_input: str) -> str:
Expand Down Expand Up @@ -120,7 +120,7 @@ def zeller(date_input: str) -> str:
)

# Get datetime obj for validation
dt_ck = datetime.date(int(y), int(m), int(d))
dt_ck = dt.date(int(y), int(m), int(d))

# Start math
if m <= 2:
Expand Down
Loading