Created
October 2, 2019 06:00
-
-
Save renyuanL/0c12849ec6354e093301c62b48d6bb29 to your computer and use it in GitHub Desktop.
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
''' | |
ryPythonHk001.py | |
解二元一次方程式001 | |
''' | |
aMessage= ''' | |
solve: | |
a x + b y = c | |
d x + e y = f | |
input: | |
a,b,c | |
d,e,f | |
solution: | |
x= ? | |
y= ? | |
''' | |
print(aMessage) | |
a= float(input('a=? ')) | |
b= float(input('b=? ')) | |
c= float(input('c=? ')) | |
d= float(input('d=? ')) | |
e= float(input('e=? ')) | |
f= float(input('f=? ')) | |
delta= a*e-d*b | |
deltaX= c*e-f*b | |
deltaY= a*f-d*c | |
x= deltaX/delta | |
y= deltaY/delta | |
print('the solution is ...') | |
print('x= ', x) | |
print('y= ', y) | |
# 驗算.... | |
p1= (a*x+b*y == c) | |
p2= (d*x+e*y == f) | |
p= p1 and p2 | |
print('驗算....') | |
print('p= ', p) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment