What am I doing wrong? Trying to compute the area of a circle. (Python) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What am I doing wrong? Trying to compute the area of a circle. (Python)

I am attempting to write a program where you input the radius of a circle and get the area of the circle as the output. I made the following code: https://code.sololearn.com/c70Co2670bYt/?ref=app No matter what my input is, I get an output of 3.14.... Please help me fix this. Thanks!

15th Jun 2017, 12:04 AM
chessmonster
chessmonster - avatar
3 Answers
+ 1
The problem is that you are using bool() instead of int() or float() EDITED: bool converts the value to 1 in this case.
15th Jun 2017, 12:14 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
thanks, Cruz. Somehow I got bool and float mixed up.
15th Jun 2017, 12:18 AM
chessmonster
chessmonster - avatar
0
import math print(math.pi*float(input())**2) Use a number type like float instead of bool. Bool will return True or False only.
15th Jun 2017, 12:19 AM
ChaoticDawg
ChaoticDawg - avatar