Professional Documents
Culture Documents
Assignment 1 Advanced Dbms
Assignment 1 Advanced Dbms
factorial=1
if a<0:
print("Factorial of a number does not exist")
elif a==0:
print("Factorial of a number is 1")
else :
for i in range(1,a + 1):
factorial = factorial*i
print("The factorial of",a,"is",factorial)
Enter a number=5
The factorial of 5 is 120
import math
def find_factors(number):
factors = []
for i in range(1, number + 1):
if number % i == 0:
factors.append(i)
return factors
number = int(input("Enter a number: "))
result = find_factors(number)
print(f"The factors of {number} are: {result}")
Enter a number: 5
The factors of 5 are: [1, 5]
def is_palindrome(input_string):
input_string = input_string.lower()
input_string = input_string.replace(" ", "")
return input_string == input_string[::-1]
string_to_check = "A man a plan a canal Panama"
result = is_palindrome(string_to_check)
if result:
print(f"'{string_to_check}' is a palindrome.")
else:
print(f"'{string_to_check}' is not a palindrome.")