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
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...
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....
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...
The code I have written runs but I need it us UDP not TCP. Also I...
The code I have written runs but I need it us UDP not TCP. Also I just need someone to check my work and make sure that it works properly. The python code needs to be run with command line so you can add more than one client. The directions: 1. The chat is performed between 2 clients and not the server. 2. The server will first start up and choose a port number. Then the server prints out its...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that...
1. Given the following multi-way if statement, provide a switch statement, using proper java syntax, that will provide the same function. Char grade; String tstmsg; if (grade == ‘A’) {   tstmsg = “Excellent”; } else if (grade == ‘B’) {   tstmsg = “Good”; } else if (grade == ‘C’) {   tstmsg = “OK”; } else {   tstmsg = “Study More”; } 2.Write the following for statement as a while statement. for (k = 0; k < 3; k++) {   System.out.println...
Consider a satellite of mass m in a circular orbit of radius r around the Earth...
Consider a satellite of mass m in a circular orbit of radius r around the Earth of mass ME and radius RE. 1. What is the gravitational force (magnitude and direction) on the satellite from Earth? 2. If we define g(r) to be the force of gravity on a mass m at a radial distance r from the center of the Earth, divided by the mass m, then evaluate the ratio g(r)/g(RE)to see how g varies with radial distance. If...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...