FACTORIAL OF A GIVEN NUMBER
def factorial(n):
if n == 1:
return n
else:
return n*factorial(n-1)
num = 8
if num == 0:
print("The factorial = 1")
else:
print("The factorial = ",factorial(num))
OUTPUT:
FACTORIAL OF A GIVEN NUMBER
def factorial(n):
if n == 1:
return n
else:
return n*factorial(n-1)
num = 8
if num == 0:
print("The factorial = 1")
else:
print("The factorial = ",factorial(num))
OUTPUT:
Hello all, in this article we are going to learn how to create a calendar using python
# importing calendar module
import calendar
yy = int(input("Enter year : ")) # 2021
mm = int(input("Enter month :")) # 10
# display the calendar
print(calendar.month(yy, mm))
# Program To make a simple calculatorwhile True: # take input from the user print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") option = input("Please Enter your option ")
# check if option is valid if option in ('1', '2', '3', '4'): num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: "))
if option == '1': print(num1, "+", num2, "=", num1+num2)
elif option == '2': print(num1, "-", num2, "=", num1-num2)
elif option == '3': print(num1, "*", num2, "=", num1*num2)
elif option == '4': print(num1, "/", num2, "=", num1/num2) # check if user wants to continue, if no # break the while loop continue_or_not = input("want to continue or not (yes or no) : ") if continue_or_not == "no": break else: print("The Input is invalid")