Calculating area


#1

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)


#2

check the parentheses on the line above the error message line


#3

@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.


#4

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


#5

@stetim94, thanks for telling me that


#6

Thanks! I got it now :slight_smile:


#7

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