Posts

Showing posts from November, 2023

Experiments

Experiment 1: Swap two numbers and check positive or negative Copy Code 1 def swap(a,b): temp = b b = a a = temp return a,b def numchecker(num): if num>0: return 1 elif num Experiment 2: To check palindrome number and string and find factorial of a number Copy Code 2 def number_palindrome(num): if 0 >= num 0: dig = num % 10 rev = rev * 10 + dig num = num // 10 if temp == rev: print("The number is a palindrome!") else: print("The number isn't a palindrome!") def string_palindrome(): word = input("Enter any word: ") temp = word temp = word[::-1] if word == temp: print("The string is palindrome") else: print("The string isn't a palindrome") def factorial(num): f = 1 if num Experiment 3: ...