0% found this document useful (0 votes)
2 views2 pages

Experiment No 04

The document contains multiple programming exercises, including calculating the area and perimeter of a circle, finding factors of a number, checking if a number is even or odd, and determining if a word is a palindrome. Each exercise includes code snippets and prompts for user input. The output of each program is also described, demonstrating the expected results.

Uploaded by

prayasambawade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Experiment No 04

The document contains multiple programming exercises, including calculating the area and perimeter of a circle, finding factors of a number, checking if a number is even or odd, and determining if a word is a palindrome. Each exercise includes code snippets and prompts for user input. The output of each program is also described, demonstrating the expected results.

Uploaded by

prayasambawade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment no:-04 3) Write a program to calculate the area

Roll no:-2040 and perimeter of circle


Code:
1) Write a program to find factor of a pi=3.14
number def calculate_area(radius):
Code: return pi * radius ** 2
def find_factors(number):
factors = [] def calculate_perimeter(radius):
for i in range(1, number + 1): return 2 * pi * radius
if number % i == 0:
factors.append(i) radius = float(input("Enter the radius of the
return factors circle: "))
num = int(input("Enter a number to find its
factors: ")) area = calculate_area(radius)
factors = find_factors(num) perimeter = calculate_perimeter(radius)
print(f"The factors of {num} are: {factors}")
OUTPUT: print(f"The area of the circle with radius
{radius} is: {area:.2f}")
print(f"The perimeter (circumference) of the
circle with radius {radius} is:
{perimeter:.2f}")

OUTPUT:
2) Write a program to find Even or Odd
number using function
Code:
def check_even_odd(number):
if number % 2 == 0:
return "Even"
else: 4) Write a program to check if given
return "Odd" word is palindrome or not
Code:
num = int(input("Enter a number: ")) def is_palindrome(word):
word = word.lower()
result = check_even_odd(num) return word == word[::-1]
print(f"The number {num} is {result}.")
OUTPUT: word = input("Enter a word: ")

if is_palindrome(word):
print(f"The word '{word}' is a
palindrome.")
else:
print(f"The word '{word}' is not a
palindrome.")

OUTPUT:

You might also like