Question

# given a radius, find the area of a circle def get_area_circle(r):        """        ...

# 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)

Homework Answers

Answer #1

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:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete ā€œCā€ program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
Implement the following functions in the given code: def random_suit_number(): def get_card_suit_string_from_number(n): def random_value_number(): def get_card_value_string_from_number(n):...
Implement the following functions in the given code: def random_suit_number(): def get_card_suit_string_from_number(n): def random_value_number(): def get_card_value_string_from_number(n): def is_leap_year(year): def get_letter_grade_version_1(x): def get_letter_grade_version_2(x): def get_letter_grade_version_3(x): Pay careful attention to the three different versions of the number-grade-to-letter-grade functions. Their behaviors are subtly different. Use the function descriptions provided in the code to replace the pass keyword with the necessary code. Remember: Parameters contain values that are passed in by the caller. You will need to make use of the parameters that each...
A bullet is shot to a target which is a circle with radius of 20 meter....
A bullet is shot to a target which is a circle with radius of 20 meter. If the bullet assumed hit the circle and the probabilty of it to hit all points in the circle is the same. What is the probability of the bullet to hit the target IF: a) at distance 4 meter from the center of the circle b) at the distance of 4 meter fro the circumference of the circle c) at the area of rectangle...
from typing import List def longest_chain(submatrix: List[int]) -> int: """ Given a list of integers, return...
from typing import List def longest_chain(submatrix: List[int]) -> int: """ Given a list of integers, return the length of the longest chain of 1's that start from the beginning. You MUST use a while loop for this! We will check. >>> longest_chain([1, 1, 0]) 2 >>> longest_chain([0, 1, 1]) 0 >>> longest_chain([1, 0, 1]) 1 """ i = 0 a = [] while i < len(submatrix) and submatrix[i] != 0: a.append(submatrix[i]) i += 1 return sum(a) def largest_rectangle_at_position(matrix: List[List[int]], x:...
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159;...
#include<iostream> #include<iomanip> using namespace std; int main() { //variables int choice; float radius,base,height,area; const double PI=3.14159; //repeat until user wants to quits while(true) { //menu cout<<endl<<endl<<"Geometry Calculator"<<endl<<endl; cout<<"1. Calculate the area of a circle"<<endl; cout<<"2. Calculate the area of a triangle"<<endl; cout<<"3. Quit"<<endl<<endl; //prompt for choice cout<<"Enter your choice(1-3): "; cin>>choice; cout<<endl; //if choice is circle if(choice==1) { cout<<"What is the radius of the circle? "; cin>>radius; //calculating area area=PI*radius*radius; cout<<endl<<"The area of the circle is "<<fixed<<setprecision(3)<<area<<endl; } //if choice...
##4. What will the following program display? ##def main(): ## x = 1 ## y =...
##4. What will the following program display? ##def main(): ## x = 1 ## y = 3.4 ## print(x, y) ## first printing ## change_us(x, y) ## print(x, y) ##second printing ## ##def change_us(a, b): ## a = 0 ## b = 0 ## print(a, b) ## ##main() ## ##Yes, yes, main() displays ##1 3.4 ##0 0 ##1 3.4 ## The question is: why x and y are still the same while the second printing of (x,y)? ## It seems...
convert this code to accept int value instead of float values using python. Make sure to...
convert this code to accept int value instead of float values using python. Make sure to follow the same code. do not change the steps and make sure to point to what code you replaced. make sure to have 2 files Method:----------------------- #define a python user difined method def get_float_val (prompt): is_num = False str_val = input (prompt) #prming read for our while #while is_num == False: (ignore this but it works) old school while not is_num: try: value =...
1. Use a calulator to find a decimal approximation for each value. sec(-216 degrees 13')= (round...
1. Use a calulator to find a decimal approximation for each value. sec(-216 degrees 13')= (round to seven decimal places) 2. A space vechile is orbiting Earth in a circular orbit. What radian measure corresponds to (a) 2.5 orbits? (b) 5/4 orbits? (a) the radian measure corresponding to 2.5 orbits is ___. (Type an axact answer in terms of pi. Type an interger or a simplified fraction) b) the radian measure corresponding to 5/4 orbits is ___. (Type an exact...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n ==...
QUESTION 1 For the following recursive function, find f(5): int f(int n) { if (n == 0)    return 0; else    return n * f(n - 1); } A. 120 B. 60 C. 1 D. 0 10 points    QUESTION 2 Which of the following statements could describe the general (recursive) case of a recursive algorithm? In the following recursive function, which line(s) represent the general (recursive) case? void PrintIt(int n ) // line 1 { // line 2...
Program will allow anywhere between 1 and 6 players (inclusive). Here is what your output will...
Program will allow anywhere between 1 and 6 players (inclusive). Here is what your output will look like: Enter number of players: 2 Player 1: 7S 5D - 12 points Player 2: 4H JC - 14 points Dealer: 10D Player 1, do you want to hit? [y / n]: y Player 1: 7S 5D 8H - 20 points Player 1, do you want to hit? [y / n]: n Player 2, do you want to hit? [y / n]: y...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT