Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- a, b, c = map(float, input('個別輸入三個數分開空格').split())
- B = b*b-4*a*c
- print(B)
- def qr(a, b, c):
- if not all(isinstance(i, (int, float)) for i in [a, b, c]):
- raise typeError('wrong')
- return
- if B < 0:
- print('no')
- elif B == 0:
- result = -b/(2*a)
- print('有相同兩個解', result)
- else:
- return(-b+math.sqrt(b*b-4*a*c))/(2*a), (b+math.sqrt(b*b-4*a*c))/(2*a)
- print('有不同兩個解', qr(a, b, c))
- qr(a, b, c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement