Created
October 25, 2018 00:24
-
-
Save sahithyandev/9228ad6bb7d4968c05b757f6e997c200 to your computer and use it in GitHub Desktop.
Find Factorial with Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is made for google code in