MCPcopy Create free account
hub / github.com/geekcomputers/Python / main

Function main

factorial_perm_comp.py:29–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28
29def 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
76if __name__ == "__main__":

Callers 1

Calls 3

permutationFunction · 0.85
combinationFunction · 0.85
factorialFunction · 0.70

Tested by

no test coverage detected