From 4951686999339c82012f6f9f6004c8ad7b918482 Mon Sep 17 00:00:00 2001 From: avivfaraj <73610201+avivfaraj@users.noreply.github.com> Date: Sat, 4 Sep 2021 10:19:15 -0400 Subject: [PATCH] Changed print to f-string Also printed out results in a math notation --- physics/gamma_function.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/physics/gamma_function.py b/physics/gamma_function.py index 395968aeb..bbef62340 100644 --- a/physics/gamma_function.py +++ b/physics/gamma_function.py @@ -64,11 +64,12 @@ if __name__ == "__main__": raise ValueError # Ensure print an error message except ValueError: - print("Invalid input: Must be an integer or an half-integer!") + print("Error: Input must be an integer or an half-integer!") number = False finally: # Ensure input is a valid number if number: + print(f"\u0393({num}) = ", end="") # Ensure input is an integer if (isinstance(gamma(num), int)): # Print result @@ -76,7 +77,7 @@ if __name__ == "__main__": # Otherwise print results with √π (gamma of 0.5 is √π) # Therefore all results will be a number times √π else: - results = "{result:.4f}".format(result=gamma(num) / sqrt(pi)) + results = f"{gamma(num) / sqrt(pi):.4f}" results = results.rstrip('0').rstrip('.') if results == "1": results = ""