Last active
April 16, 2024 21:09
-
-
Save Adobe-Android/6a9d00d604b21dfc971a589c32f20760 to your computer and use it in GitHub Desktop.
Find the percentage difference between two numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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