i. Write a python program to calculate the factorial value of a given
number. The number must be entered by the user.
ii. Write a Python program to print the following pattern :
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Answers
Answered by
0
Answer
num = input('Enter the number which needs to be factorialized")
factorial = 1
# check if the number is negative, positive or zero
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)
Pattern Program:
rows = 6
for num in range(rows):
for i in range(num):
print(num, end=" ") # print number
# line after each row to display pattern correctly
print(" ")
Explanation:
Answered by
0
Explanation:
kyaa kru mai marr jau meri koi feeling nhi hai....
Similar questions