Python Forum
Python Question - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Python Question (/thread-18692.html)



Python Question - Smhbugra - May-27-2019

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))


RE: Python Question - buran - May-27-2019

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.


RE: Python Question - calvinpdaw - May-27-2019

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.