Python Programs
Python Programs
8. Calculate Factorial:
n = int(input("Enter a number: "))
factorial = 1
for i in range(1, n + 1):
factorial *= i
print("Factorial is:", factorial)
if operation == '+':
result = num1 + num2
elif operation == '-':
result = num1 - num2
elif operation == '*':
result = num1 * num2
elif operation == '/':
if num2 == 0:
result = "Cannot divide by zero"
else:
result = num1 / num2
else:
result = "Invalid operation"