Python Forum
function with radius as a parameter that returns area of a circle - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: function with radius as a parameter that returns area of a circle (/thread-8129.html)



function with radius as a parameter that returns area of a circle - taydeal20 - Feb-06-2018

Instructions: Write a function named circle_area that accepts the radius of a circle as a parameter (as a number) and returns the area of a circle with that radius. For example, the call of area(2.0) should return 12.566370614359172. You may assume that the radius passed is a non-negative number.

How would I start this?


RE: function with radius as a parameter that returns area of a circle - Larz60+ - Feb-07-2018

start with:
radius = input('Enter radius: ')



RE: function with radius as a parameter that returns area of a circle - buran - Feb-07-2018

first line of the function would be
def circle_area(radius):
from there, you need to write the body of function and ask specific questions. Don't forget to post all of your code in python tags as well as full traceback (if you get one) in error tags


RE: function with radius as a parameter that returns area of a circle - taydeal20 - Feb-07-2018

I'm trying to run this but it gives me a blank output.

import math

def circle_area(radius):
    CircArea = (math.pi * (radius) ** 2)

circle_area(2.0)



RE: function with radius as a parameter that returns area of a circle - buran - Feb-07-2018

1. your function need to return something. what?
2. when you call the function, you need to use what it will return...