2018年1月8日 星期一

Python: Input the radius of a circle and compute the area

Python: Input the radius of a circle and compute the area

Python Basic: Exercise-4 with Solution

Write a Python program which accepts the radius of a circle from the user and compute the area.
Python: Area of a Circle
In geometry, the area enclosed by a circle of radius r is πr2. Here the Greek letter π represents a constant, approximately equal to 3.14159, which is equal to the ratio of the circumference of any circle to its diameter.
Python: Area of a circle
Sample Solution:-
from math import pi
r = float(input ("Input the radius of the circle : "))
print ("The area of the circle with radius " + str(r) + " is: " + str(pi * r**2))

=========== RESTART: F:/Python_APSC/py-ex-basic-4.py ============
Input the radius of the circle : 10
The area of the circle with radius 10.0 is: 314.1592653589793
>>> 





沒有留言:

張貼留言

使用 ICDT的 MQTT WS HMI MQTT Port = 8000 與 Wokwi ESP32 MQTT port=1883 資料交換

使用 ICDT的 MQTT WS HMI  MQTT Port = 8000  與 Wokwi ESP32 MQTT port=1883  資料交換   這個系統是一個典型的 工業物聯網 (IIoT) 遠端監控架構 。它結合了硬體模擬、雲端訊息中轉以及網頁圖控介面,讓您能透過瀏覽...