-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dae3ac2
commit e078e71
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Programa para calcular el área de un círculo. | ||
# El programa solicita al usuario el radio del círculo y calcula su área y su perímetro. | ||
# Finalmente mostrará por la consola o terminal el resultado de los cálculos. | ||
|
||
import math | ||
|
||
# 1. Toma de datos | ||
|
||
def calcular_area_circulo(radio): | ||
return math.pi * radio ** 2 | ||
|
||
def calcular_perimetro_circulo(radio): | ||
return 2 * math.pi * radio | ||
|
||
# 2. Solicitar al usuario el radio del círculo | ||
|
||
radio = float(input("Introduce el radio del círculo: ")) | ||
|
||
# 3. Cálculo del área y el perímetro | ||
|
||
area = calcular_area_circulo(radio) | ||
perimetro = calcular_perimetro_circulo(radio) | ||
|
||
# 4. Mostrar resultados | ||
|
||
print(f"El área del círculo con radio {radio} es {area:.2f}") | ||
print(f"El perímetro del círculo con radio {radio} es {perimetro:.2f}") | ||
|
||
|
||
|
||
|
||
|