EXPT6
EXPT6
THEORY:-
ALGORITHM:-
Start
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Exponentiation (x^y)
Factorial (x!)
If operation is 1 (Addition):
If operation is 2 (Subtraction):
If operation is 3 (Multiplication):
Input: Read num1 and num2.
If operation is 4 (Division):
If num2 is 0:
Else:
If operation is 5 (Exponentiation):
If operation is 6 (Factorial):
If num < 0:
Else:
If invalid operation:
End
FLOWCHART:-
CODE:-
import math
def calculator():
print("Choose an operation:")
if operation == '1':
if num2 != 0:
else:
if num < 0:
else:
result = math.factorial(num)
calculator()
OUTPUT:-
Choose an operation:
1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
5. Exponentiation (x^y)
6. Factorial (x!)