Computer Science, asked by ramsmedicine, 1 month ago

over the 2nd line what should come any idea pls tell. This is abt python i hope u will help in this at least

Attachments:

Answers

Answered by Equestriadash
56

Given co‎‎de:

r = float(input("2")

print = "(a = math pi")

print("Area = ", 12.56)

p = 2*3.14*12.56

print("Perimeter = ", )

Corrected c‎ode:

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 \tt import\ math. There are various other modules as well, another common one being \tt statistics, 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 co‎de 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.

Answered by BrainlyProgrammer
14

Your Approach:-

  1. r = float(input("2")
  2. print = "(a = math pi")
  3. print("Area = ", 12.56)
  4. p = 2*3.14*12.56*
  5. print("Perimeter = ", )

After correction:-

  1. import math
  2. r = float(input("Enter the radius: "))
  3. print("Area = ", ((r* *2)*(math.pi)))
  4. p = 2*math.pi*r
  5. 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)
Similar questions