Calculating area


I wrote this program, everything seems fine to me but python keeps saying invalid syntax . It also keeps highlighting ‘area’ in the 2nd line. Any idea why?

import math

radius = int(input("Enter the radius: ")
area = math.pi * (radius ** 2)
print("Radius is: ", radius)
print(“Area is:%.2f”, %area)


check the parentheses on the line above the error message line


@emerald_56 , I think on the line where you put

print("Radius is:", radius)

you need to put

print("Radius is:" + radius)

you forgot the + sign to add the variable Radius to the string Radius is.


there are multiply ways to concat strings, both is valid. Please check your suggestion, you forgot a quotation marks at the start of your string


@stetim94, thanks for telling me that


Thanks! I got it now :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.