Python Online Compiler
Example: How to Find Area of a Circle with Diameter in Python using Functions
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# How to Find Area of a Circle with Diameter in Python using Functions # To calculate the diameter def Diameter(r): return 2 * r # To calculate the circumference def Circumference(r): return 2 * 3.14 * r # To calculate the area def Area(r): return 3.14 * (r * r) # It's the driver code print("Enter the radius of the circle::\n") r = float(input()) # r = radius # It will print the final output print("Diameter = ", Diameter(r), "units") print("Circumference = ", Circumference(r), "units") print("Area = ", Area(r), " sq. units")
10
Output
Clear
ADVERTISEMENTS