Area Calculator _ Error line 11


Hi everyone,

The last hour I’ve been unable to find the mistake the terminal is pointing out, while trying to test out the validity of the first half of the Area Calculator exercise.

I could totally use a second pair of eyes. Please advice accordingly, thanks in advance…

Area Calculator

print ‘Calculation in action!’

option = raw_input("Enter C or Circle for Circle or T or Triangle for Triangle: ")

if option == ‘C’ or option == ‘Circle’:
radius = float(raw_input('Enter radius: '))
area = 3.14 * radius ** 2
print ‘Area is %s’ % area


Were we instructed to use 3.14 or pi?

from math import pi


Hi mtf, thanks for replying.

Apparently they have changed the instructions into a more streamlined exercise.


Please post a link to the exercise. Thanks.


You got it!


This is a free form project so no lesson checker

I would reduce the inputs to just C or T and accept both lower and upper case.

if option.lower in 'ct':

For greater precision use the PI constant,

from math import pi

If you use a float to multiply, the input does not need to be cast to float. Let the user input anything they wish.

print ‘Area is %s’ % area

is old school. Suggest use .format or an f-string (Python 3.6 or higher).


@mtf thanks a lot for your time & the help.

I followed your suggestions to: from math import pi, reduced C,T inputs in lower.(), erased the float cast and used f-string method instead of %s,

but unfortunately it’s still reflecting the same error in line_11: area = pi * radius ** 2


Please post your revised code and we can test it. I don’t think the LE is 3.6 or higher. May have to revert to str.format().


Area Calculator
from math import pi
print ‘Calculation in action!’

option = raw_input("Enter C or T for Circle or Triangle respectively: ")

if (option.lower()) == ‘C’:
radius = raw_input('Enter radius: ')
area = pi * radius ** 2
print f"Area is {area}"

#I also tried “Area is %f” %area

 if option.lower() == 'c':


If you want it to be obvious that pi is a constant,

>>> from math import pi as PI
>>> PI


Thanks, I corrected it, but still… line_11 is doomed!


I don’t think you can use f-strings in the LE. Use str.format(), instead.

Redo all your indentaion using spaces, 2 or 4, but 4 are more obvious.

$ python
2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609]
Calculator is starting on 18/12/2018 at 23:57
Enter C for Circle or T for Triangle:c
Enter the radius:1
The pie is baking...
The area is 3.14.
Don't forget to include the correct units!


Ok, after I redid the identations it worked, we’ve made some progress:

Tried these 2 scenarios and in both I get an error regarding the exponentiation **


My bad… The input is a string that needs to be cast to a float. Fifty lashes with a wet noodle.


Haha no worries, let me correct it real quick.

Update: Wooooohooooo!!! It worked!


One last point… If we want to permit the user to type,


we can by zeroing in on the first character.

if option[0].lower() == 'c':


Good point!

Thanks again for the help, very much appreciated.

It’s my 1st week learning Python and it’s been exciting with all the support. Looking forward to reach a more advanced level and start asking the “real” questions :smiley:


All questions are real (as pertains to lessons and code in general) from where I stand. The really tough ones are more the challenge to answer. Keep up the groove and you’ll meet some experts in the tougher tracks.