Skip to content

Instantly share code, notes, and snippets.

@Adobe-Android
Last active April 16, 2024 21:09
Show Gist options
  • Save Adobe-Android/6a9d00d604b21dfc971a589c32f20760 to your computer and use it in GitHub Desktop.
Save Adobe-Android/6a9d00d604b21dfc971a589c32f20760 to your computer and use it in GitHub Desktop.
Find the percentage difference between two numbers
#!/bin/env python3
def main():
num1 = 80
num2 = 100
absolute = abs(num1 - num2)
average = (num1 + num2) / 2
answer = round((absolute / average) * 100)
print(f"Difference of {answer}%")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment