Computer Science, asked by sudhanshu5842, 3 months ago

PLEASE FIND THE ALGORITHM OF THIS GIVEN VALUE.

1.To find out area and circumference of a circle for given value of radius. (Hint: area = πr^2, and circumference= 2πr)
2.To find factorial of a given integer number
3.To find addition of first 15 odd numbers (Hint: starting from 1)
4.To find the maximum number from given 3 integer numbers.​

Answers

Answered by jai696
3

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

from math import pi

# find area of circle

circle_area = lambda r: pi * (r ** 2)

# find circumference of a circle

circle_circumference = lambda r: 2 * pi * r

# find factorial of a number

def factorial(n):

factorial = 1

if n == 0:

return factorial

for x in range(1, n + 1):

factorial *= x

return factorial

# find sum of 15 odd numbers

def sum_odd_nums():

_sum = 0

for n in range(1, 16):

if n % 2 != 0:

_sum += n

return _sum

# find max of 3 numbers

def max_num(nums):

_max = nums[0]

for n in nums:

if _max < n:

_max = n

return _max

# use all the functions

print(circle_area((r := float(input("radius: ")))))

print()

print(circle_circumference((r := float(input("circumference: ")))))

print()

print("factorial:", factorial((n := int(input("factorial of: ")))))

print()

print("sum of 15 odd nums:", sum_odd_nums())

print()

print("max:", max_num((nums := list(map(int, input("3 nums: ").split())))))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions