# given a radius, find the area of a circle
def get_area_circle(r):
"""
what it takes
radius of a circle (any positive real number)
what it does:
computes the area of a circle
given a radius, find the area of a circle
area = pi*r2 (pi times r squared)
what it returns
area of a circle. Any positive real number (float)
"""
# your code goes in here
return
Test Case for Question 3. Do not delete or alter the cell below
try:
if ((get_area_circle(5) > 78) and
(get_area_circle(5)<79)):
score['question 3'] =
'pass'
else:
score['question 3'] =
'fail'
except:
score['question 3'] = 'fail'
get_area_circle(5)
# Given a number, this function will compute the factorial
def get_factorial(number):
"""
what it takes?
number to calculate its factorial
what it does?
given a number, find its factorial such as 5! = 20
Do not use a python built-in function - code it
what it
returns?
factorial of a number
5! shoukld return 120
It will return integer
"""
# your code goes in here
return
Test Case for Question 4. Do not delete or alter the cell below
try:
if get_factorial(5) == 120:
score['question 4'] =
'pass'
else:
score['question 4'] =
'fail'
except:
score['question 4'] = 'fail'
get_factorial(5)
import math
# given a radius, find the area of a circle
def get_area_circle(r):
"""
what it takes
radius of a circle (any positive real number)
what it does:
computes the area of a circle
given a radius, find the area of a circle
area = pi*r2 (pi times r squared)
what it returns
area of a circle. Any positive real number (float)
"""
# your code goes in here
area=math.pi*(r*r);
return area;
print(get_area_circle(5));
# Given a number, this function will compute the factorial
def get_factorial(number):
"""
what it takes?
number to calculate its factorial
what it does?
given a number, find its factorial such as 5! = 20
Do not use a python built-in function - code it
what it returns?
factorial of a number
5! shoukld return 120
It will return integer
"""
# your code goes in here
if(number==0):
return 1;
return number*get_factorial(number-1);
print(get_factorial(5));
Code screenshot:
Expected output:
Get Answers For Free
Most questions answered within 1 hours.