Skip to content

Instantly share code, notes, and snippets.

@sahithyandev
Created October 25, 2018 00:24
Show Gist options
  • Save sahithyandev/9228ad6bb7d4968c05b757f6e997c200 to your computer and use it in GitHub Desktop.
Save sahithyandev/9228ad6bb7d4968c05b757f6e997c200 to your computer and use it in GitHub Desktop.
Find Factorial with Python
def factorial(start): # Function to find factorial
numbers = list(range(1, start+1)) # Getting the list to find factorial
factorial = 1 # defining the factorial as 1
for number in numbers: # In the list of numbers, Get numbers one by one
factorial *= number # and multiplying it by the factorial and save it to factorial
rounding = "{:0.2f}".format(factorial) # Rounding the factorial
print(rounding) # Outputting the factorial as rounded
def getin(): # Function to get inputs
try:
start = int(input("Enter A Number to Find Factorial Number : ")) # Trying to get the input number
factorial(start) # Passing it to find the factorial
except ValueError: # If a value error occurs
print("Enter a number (Integer) only...") # Telling the user to input only number
getin() # Getting the input again
getin() # Calling getin() function
@sahithyandev
Copy link
Author

This is made for google code in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment