Python Forum
function with radius as a parameter that returns area of a circle
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function with radius as a parameter that returns area of a circle
#1
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?
Reply
#2
start with:
radius = input('Enter radius: ')
Reply
#3
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
Reply
#4
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)
Reply
#5
1. your function need to return something. what?
2. when you call the function, you need to use what it will return...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How Can I Draw Circle With Turtle İn Python ? mdm 2 2,758 Jun-03-2021, 02:07 PM
Last Post: DPaul
Photo I need help with a circle random color code and error Vxploit 4 3,022 Mar-21-2021, 07:23 PM
Last Post: jefsummers
  Turtle circle Fabio87 3 2,491 Dec-17-2020, 10:52 PM
Last Post: Fabio87
  Calculate area of a circle pythonuser1 20 7,076 Apr-15-2020, 03:18 AM
Last Post: Skaperen
  A function taking in parameter int and str GrosseGaro 1 2,366 Sep-25-2019, 06:20 PM
Last Post: ichabod801
  Intersection of a triangle and a circle Gira 3 3,629 May-19-2019, 06:04 PM
Last Post: heiner55
  Need of return in function if statement inside the function already returns Athul 5 3,927 Aug-16-2018, 10:19 AM
Last Post: DuaneJack
  parameter in function being involuntarily converted to str?? juliabrushett 8 4,613 Jul-03-2018, 04:23 PM
Last Post: gruntfutuk
  Recursive function with a parameter MOH 0 2,078 Apr-30-2018, 09:39 PM
Last Post: MOH
  radius of circle question charlottecrosland 5 4,248 Sep-11-2017, 09:50 AM
Last Post: charlottecrosland

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020