2018年1月9日 星期二

Python: Calculate midpoints of a line

Python: Calculate midpoints of a line

Python Basic: Exercise-73 with Solution

Write a Python program to calculate midpoints of a line.
Sample Solution:-
print('\nCalculate the midpoint of a line :')
x1 = float(input('The value of x1 (the first endpoint) '))
y1 = float(input('The value of y1 (the first endpoint) '))
x2 = float(input('The value of x2 (the second endpoint) '))
y2 = float(input('The value of y2 (the second endpoint) '))

x_m_point = (x1 + x2)/2
y_m_point = (y1 + y2)/2
print();
print("The midpoint of line is :")
print( "The midpoint's x value is: ",x_m_point)
print( "The midpoint's y value is: ",y_m_point)
print();

========== RESTART: F:/Python_APSC/py-ex-basic-73.py =========

Calculate the midpoint of a line :
The value of x1 (the first endpoint) 12
The value of y1 (the first endpoint) 90
The value of x2 (the second endpoint) 45
The value of y2 (the second endpoint) 10

The midpoint of line is :
The midpoint's x value is:  28.5
The midpoint's y value is:  50.0

>>> 

沒有留言:

張貼留言

CRC(循環冗餘檢查)

  CRC(循環冗餘檢查) 完整的 CRC(循環冗餘檢查)逐步演示器 。它支援自定義 生成多項式 與 資料位元流 ,並透過「下一步」按鈕展示二進制長除法(XOR 運算)的過程。 二進制長除法模擬 : CRC 的核心是模二除法(Modulo-2 Division),實務上就是不斷進...