# Prog with file implementation for factorial print("Program to find factorial with file implementation: ") a = int(input("Enter number to find factorial: ")) fact = 1 for i in range(a): fact *= (i + 1) f = open("factorial.txt", "w") f.write("Program to find factorial of a number using file handling:\n") f.write("The factorial of " + str(a) + " is " + str(fact)) f.close() # Prog with file implementation for prime number print("\n\nProgram to find prime number with file implementation: ") a = int(input("Enter number to check if prime number: ")) flag = False for i in range(2, a//2): if (a%i) == 0: flag = True break output = str(a) + " is a prime number." if flag: output = str(a) + " is not a prime number." f = open("prime_num.txt", "w") f.write("Program to chcek if a number is prime number using file handling:\n") f.write(output) f.close() # Prog with file implementation for palindrom str print("\n\nProgram to find prime number with file implementation: ") a = input("Enter number to check if prime number: ") rev = "" for i in range(len(a)): rev += a[len(a) - i - 1] if a == rev: output = str(a) + " is a palindrome string." else: output = str(a) + " is not a palindrome string." f = open("reverse.txt", "w") f.write("Program to chcek if a number is palindrome using file handling:\n") f.write(output) f.close()