Python Forum

Full Version: Python Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Compare the two codes shown below and state the output if the input entered in each case is -6?

CODE 1
import math
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))

CODE 2
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))
You've been advised to read and follow forum rules.
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
also, please use descriptive thread titles

and because this looks like homework assignment, I move it in the proper sub-forum.
The first code results in a valueError. This is because when we enter the input as solution -6, we are trying to find of negative number, which isn't possible. The second code results in nameError. So not undefined.