()
| 27 | |
| 28 | |
| 29 | def main(): |
| 30 | print("choose between operator 1,2,3") |
| 31 | print("1) Factorial") |
| 32 | print("2) Permutation") |
| 33 | print("3) Combination") |
| 34 | |
| 35 | operation = input("\n") |
| 36 | |
| 37 | if operation == "1": |
| 38 | print("Factorial Computation\n") |
| 39 | while True: |
| 40 | try: |
| 41 | n = int(input("\n Enter Value for n ")) |
| 42 | print("Factorial of {} = {}".format(n, factorial(n))) |
| 43 | break |
| 44 | except ValueError: |
| 45 | print("Invalid Value") |
| 46 | continue |
| 47 | |
| 48 | elif operation == "2": |
| 49 | print("Permutation Computation\n") |
| 50 | |
| 51 | while True: |
| 52 | try: |
| 53 | n = int(input("\n Enter Value for n ")) |
| 54 | r = int(input("\n Enter Value for r ")) |
| 55 | print("Permutation of {}P{} = {}".format(n, r, permutation(n, r))) |
| 56 | break |
| 57 | except ValueError: |
| 58 | print("Invalid Value") |
| 59 | continue |
| 60 | |
| 61 | elif operation == "3": |
| 62 | print("Combination Computation\n") |
| 63 | while True: |
| 64 | try: |
| 65 | n = int(input("\n Enter Value for n ")) |
| 66 | r = int(input("\n Enter Value for r ")) |
| 67 | |
| 68 | print("Combination of {}C{} = {}".format(n, r, combination(n, r))) |
| 69 | break |
| 70 | |
| 71 | except ValueError: |
| 72 | print("Invalid Value") |
| 73 | continue |
| 74 | |
| 75 | |
| 76 | if __name__ == "__main__": |
no test coverage detected