Issue with writing a function

So I’m learning python and I’m having trouble with this practice problem and don’t know where im going wrong. The prompt:
Write a function computing the perimeter of a circle given its radius.

First read the function tutorial.

Your function should be named circle_perimeter(radius), where the radius parameter is the radius of a cirle.

Your function should return the perimeter of a circle of the given radius.

To test it, we will import your function and try it with different values, such as:

>>> circle_perimeter(1)
6.283185307179586
>>> circle_perimeter(10)
62.83185307179586
>>> circle_perimeter(100)
628.3185307179587

My solution:
import math
from math import pi
def circle_perimeter(radius):
radius = 2picircle_perimeter
return circle_perimeter
Obviously I’m stuck but don’t know where to go and the examples don’t give this type of scenario. Any help or directions would be greatly appreciated

Please format your code with </>.

You seem to be writng your python code using pascal syntax, i think.

Its not a python requirement to assign to rhe function name.

You need to return 2 * math.pi * radius.

1 Like

The function is called circle_perimeter and the radius is being passed in.

The first line of your function is:

radius = 2*pi* circle_perimeter

You’re trying to multiple the function by 2*pi to give you the radius, but you can’t multiply a function, and you already have the radius.

The second line of your function is:

return circle_perimeter

You’re returning the function itself, not the perimeter, which you haven’t calculated anyway.

1 Like

The consequence of this is that you want a third name such as
perimeter to be the result of that computation. And then return that
name.

Cheers,
Cameron Simpson cs@cskk.id.au

1 Like

Worked like a charm, I didn’t think it would be that simple