0

What's wrong?

from math import pi def roundarea(radius): if radius>0: return sqr(radius) * pi else: return "Wrong!" rndr = roundarea x = input ("Radius is: ") print(rndr(x))

5th Aug 2018, 9:26 AM
Svyatoslav Skopyuk
Svyatoslav Skopyuk - avatar
7 Antworten
+ 1
Try this: import math def roundarea(radius): if radius>0: return math.sqrt(radius) * math.pi else: return "Wrong!" x = int(input ("Radius is: ")) print(roundarea(x)) You have used a function named sqr() which was not defined. So I used the math module in Python to calculate the square-root and to get the Pi values. And I also converted the input to an integer using the int() function.
5th Aug 2018, 9:44 AM
Nadun Kulatunge
Nadun Kulatunge - avatar
0
The same
5th Aug 2018, 9:34 AM
Svyatoslav Skopyuk
Svyatoslav Skopyuk - avatar
0
what's the error?
5th Aug 2018, 9:37 AM
Nadun Kulatunge
Nadun Kulatunge - avatar
0
Radius is: print(roundarea(x)) in the end
5th Aug 2018, 9:43 AM
Svyatoslav Skopyuk
Svyatoslav Skopyuk - avatar
0
from math import pi def roundarea(radius): if radius>0: return sqr(radius) * pi else: return "Wrong!" x = input ("Radius is: " ) print(roundarea(x)) Result: Radius is: print(roundarea(x))
5th Aug 2018, 9:44 AM
Svyatoslav Skopyuk
Svyatoslav Skopyuk - avatar
0
Not sqrt, sqr And it's wrong too
5th Aug 2018, 9:56 AM
Svyatoslav Skopyuk
Svyatoslav Skopyuk - avatar
5th Aug 2018, 9:57 AM
Nadun Kulatunge
Nadun Kulatunge - avatar