In python, don't know why, it some kind of logic error, as in it's not the right number, where i'm supposed to create a algorithm which calculate area of a circle from the radius.
Asked
Active
Viewed 220 times
-7
-
1why not writing down your code ? You should search for geometry formula (obvisouly wrong) – yunandtidus Jun 19 '18 at 09:52
-
You can post your code in your question. Posting an image is just wrong... Besides that you should look up the equations and/or take a look at basic math books. You seem to have problems with transforming equations. – JE_Muc Jun 19 '18 at 09:56
-
you assign to `area` the value of the radius, and assign the name `radius` to a function that outputs the circumference... why? why?!? my OCD can't handle this – Ofer Sadan Jun 19 '18 at 10:09
5 Answers
1
math.sqrt()
means calculate Square Root Calculations(√). You just need
r * r
to solve this problem.

Ofer Sadan
- 11,391
- 5
- 38
- 62

Edward
- 21
- 5
0
use this
area = (22/7)((r)**2)
hope it helps .

Dark North
- 126
- 2
-
please don't use `22/7`, it's a really bad approximation for `pi`, at least with writing `3.142` explicitly he knows his error range. plus he already did `import math`, he could actually use `math.pi` – Ofer Sadan Jun 19 '18 at 10:10
0
You can calculate area of circle without defining any function.
Try this:
pi = 3.142
r = float(input("enter your radius of circle: "))
Area = pi * r * r
print("Area of the circle is: ", area)

user1234
- 257
- 2
- 13
0
The Below is to Find the radius and circumference of circle
# Name
Name = raw_input("Enter Your Name: ")
# Give area for the circle
Area = input("Enter Area of the circle: ")
PI = 3.14
# Calculation of radius and circumference
R = (Area / PI )**0.5
C = (2 * PI * R)
print "Area of the Circle = %.2f"%Area
print "Radius of Circle = %.2f"%R
print "Circumference of Circle = %.2f"%C

Das_Geek
- 2,775
- 7
- 20
- 26

Sudarshan G
- 21
- 3
-
1Please note the conventions for formatting [How do I format my posts using Markdown or HTML](http://stackoverflow.com/help/formatting). – help-info.de Jan 08 '20 at 08:52
0
def computeArea(val):
area=pi*(val**2)
return area
pi=3.14
inputText=input("does the question give a diameter(d) or radius(r)")
if inputText=='r':
radius=int(input("what is the radius"))
print(f"area of the circle is {computeArea(radius)}")
elif inputText=='d':
D=int(input("what is the diameter"))
r=(D/2)
area=computeArea(r)
print(f"area of the circle is {computeArea(r)}")
else:
print("You entered an incorrect value you can either type r for radius or d for diameter")
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 17 '23 at 12:28