Professional Documents
Culture Documents
ASSIGNMENT-3
SWE1004-INTRODUCTION TO PROGRAMMING IN PYTHON
OUTPUT:
CODE:
OUTPUT:
3) Write a Python Program to Find the Factorial of a Number
CODE:
num = int(input("Enter the number that you wanted to find the factorial :
"))
factorial = 1
if num == 0 or num == 1 :
print(f"The factorial of {num} is 1")
elif num <0:
print(f"Factorial for the {num} doesn't exist")
else:
for i in range(1 , num+1):
factorial = i*factorial
print(f"Factorial of {num} is {factorial}")
OUTPUT:
CODE:
CODE:
OUTPUT: