Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Question
#1
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))
#2
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

#3
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.


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020