179k views
1 vote
4

Multiple Choice
You wrote a program to find the factorial of a number. In mathematics, the factorial operation is used for positive integers and zero.
What does the function return if the user enters a negative three?
def factorial number):
product = 1
while number > 0
product = product number
number = number - 1
return product
strNum = input("Enter a positive integer")
num = int(str Num)
print(factorial(num))
O-6
O-3
O There is no output due to a runtime error.
0 1
< PREVIOUS
NEXT >
SAVE
SUBMIT
© 2016 Glynlyon, Inc. All rights reserved.
V6.0 3-0038 20200504 mainline

1 Answer

3 votes

The function will output positive 1 to the console. This happens because we declare product as 1 inside our function and that value never changes because the while loop only works if the number is greater than 0.

User MLister
by
7.6k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.