0
How to make a python program to calculate area of circle when radius should be input of user
9 Réponses
+ 5
This a really simple task. use input(...) to get the radius as int from user. The formula for the calculation is:
area = (math.pi * (radius**2))
To use the pi constant you have to import math in the top of your code.
+ 3
Astaturini M3
What's the code that you're having trouble with?
+ 1
Rather than surrounding r**2 in the int() function, I would recommend instead surrounding input() in it as to allow for whatever input the user enters automatically be interpreted as an integer. As for pi, rather than using 22/7, you could just import the math module and use the math.pi function as that will return a more accurate value of the number
+ 1
All you would need to do is just replace input() with int(input()) and you should be good for that 👍
+ 1
r=int(input())
pi=22/7
print(pi*r**2)
0
I am trying but it is not working
0
r = input()
pi = 22/7
print(int(r**2)*pi)
0
How to make an input to be integer
0
Thanks master