Skip to content

Instantly share code, notes, and snippets.

@AMMullan
Created August 6, 2024 15:42
Show Gist options
  • Save AMMullan/b1fe5db50818f949aab08a259abf1fd4 to your computer and use it in GitHub Desktop.
Save AMMullan/b1fe5db50818f949aab08a259abf1fd4 to your computer and use it in GitHub Desktop.
def percent_of(x: float, y: float) -> float:
return (x / 100) * y
def what_percent_of(x: float, y: float) -> float:
return (x / y) * 100
def percent_change(x: float, y: float) -> float:
return ((y - x) / x) * 100
x = 10
y = 100
print(percent_of(x, y))
x = 166
y = 1006
print(what_percent_of(x, y))
y = 90
x = 100
print(percent_change(x, y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment