over the 2nd line what should come any idea pls tell. This is abt python i hope u will help in this at least
Answers
Given code:
r = float(input("2")
print = "(a = math pi")
print("Area = ", 12.56)
p = 2*3.14*12.56
print("Perimeter = ", )
Corrected code:
import math
r = float(input("Enter the radius: "))
a = r**2*math.pi
print("Area = ", a)
p = 2*math.pi*r
print("Perimeter = ", p)
Before directly calling a function, you need to ensure that it is first imported. We import the Math module by simply typing . There are various other modules as well, another common one being , that is widely used for statistics purposes.
Squaring/exponentiation in python can be represented using double asterisks.
Also, the reason there was a syntax error in your code is that the string quoting and bracketing weren't correctly typed. There was an unmatched closing bracket after the closing quote. Unmatched quotes/brackets can lead to errors.
Your Approach:-
- r = float(input("2")
- print = "(a = math pi")
- print("Area = ", 12.56)
- p = 2*3.14*12.56*
- print("Perimeter = ", )
After correction:-
- import math
- r = float(input("Enter the radius: "))
- print("Area = ", ((r* *2)*(math.pi)))
- p = 2*math.pi*r
- print("Perimeter = ", p)
What was the error in your approach?
- Did not import math package
- Line 1: Although no mistake but I assume you were trying to take input there..well you can use this...
r=2
- Line 2: Wrong syntax of printing and you cannot store value of math.pi in 'a' in double quotes, of course while printing too you cannot
- Line 3: how can you assume area to be 12.56 also, variable new cannot start with numbers
- If you assume radius is 12.56, you can directly do this...
r=12.56 instead of accepting Input.
- Line 4: It's better to use math.pi than writing 3.14
- Line 5: Oof! again wrong syntax... remove last *
- print("Perimeter=",p)