Skip to content

Commit 4951686

Browse files
authored
Changed print to f-string
Also printed out results in a math notation
1 parent a565258 commit 4951686

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

physics/gamma_function.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,20 @@ def test_gamma() -> None:
6464
raise ValueError
6565
# Ensure print an error message
6666
except ValueError:
67-
print("Invalid input: Must be an integer or an half-integer!")
67+
print("Error: Input must be an integer or an half-integer!")
6868
number = False
6969
finally:
7070
# Ensure input is a valid number
7171
if number:
72+
print(f"\u0393({num}) = ", end="")
7273
# Ensure input is an integer
7374
if (isinstance(gamma(num), int)):
7475
# Print result
7576
print(gamma(num))
7677
# Otherwise print results with √π (gamma of 0.5 is √π)
7778
# Therefore all results will be a number times √π
7879
else:
79-
results = "{result:.4f}".format(result=gamma(num) / sqrt(pi))
80+
results = f"{gamma(num) / sqrt(pi):.4f}"
8081
results = results.rstrip('0').rstrip('.')
8182
if results == "1":
8283
results = ""

0 commit comments

Comments
 (0)