Computer Science, asked by tenzingjampa978, 11 months ago

write a program in python to input a no and find the factorial of an even no.​

Answers

Answered by tanika
2

Answer:

Explanation:

# Python program to find the factorial of a number provided by the user.

# change the value for a different result

num = 7

# uncomment to take input from the user

#num = int(input("Enter a number: "))

factorial = 1

# check if the number is negative, positive or zero

if num < 0:

  print("Sorry, factorial does not exist for negative numbers")

elif num == 0:

  print("The factorial of 0 is 1")

else:

  for i in range(1,num + 1):

      factorial = factorial*i

  print("The factorial of",num,"is",factorial)

Answered by SparklingThunder
0

 \huge  \purple{ \underline{ \boxed{ \red{ \mathbb{ANSWER : }}}}}

 \red{ \textsf{n=int(input("Enter number to find factorial : "))}}

 \red{ \textsf{fact=1}}

 \red{ \textsf{for i in range(1,n+1):}}

 \red{ \textsf{	 \:  \:  \:  \: fact=fact*i}}

 \red{ \textsf{print("Factorial of ",n,"is",fact)}}

 \large \green{ \underline{ \underline{ \mathbb{KNOW  \: MORE :}}}}

 \large\orange{ \textsf{for}}

for is the keyword in python which is used to form a loop whose definite length is known , it does not takes the last value . For example , the above loop will run till the number 'n' entered by the user and not till 'n+1' .

 \large\orange{ \textsf{print}}

print is the keyword in python programming language . It print anything which is written within it .

 \large\orange{ \textsf{input}}

input takes the input from the user in the form of string .

 \large\orange{ \textsf{int}}

int converts the input into integer form .

Similar questions