|
|
Line 1: |
Line 1: |
− | Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
| |
− | Type "help", "copyright", "credits" or "license()" for more information.
| |
− | >>> print ('TUGAS METNUM')
| |
− | print ('misalkan terdapat persamaan linier dua variable \n ax+by=c \n px+qy=r')
| |
− | a= float(input('nilai a='))
| |
− | b= float(input('nilai b='))
| |
− | c= float(input('nilai c='))
| |
− | p= float(input('nilai p='))
| |
− | q= float(input('nilai q='))
| |
− | r= float(input('nilai r='))
| |
| | | |
− | if a==p:
| |
− | k=b-q
| |
− | j=c-r
| |
− | y=j/k
| |
− | x=(c-(b*y))/a
| |
− | print ('nilai x',x,'nilai y',y)
| |
− |
| |
− | elif a==0:
| |
− | y=c/b
| |
− | x=(r-(q*y))/p
| |
− | print('nilai x', x, 'nilai y', y)
| |
− | elif b==0:
| |
− | x=c/a
| |
− | y=(r-(p*x))/q
| |
− | print('nilai x', x, 'nilai y', y)
| |
− | elif p==0:
| |
− | y=r/q
| |
− | x=(c-(b*y))/a
| |
− | print('nilai x', x, 'nilai y', y)
| |
− | elif q==0:
| |
− | x=r/q
| |
− | y=(c-(a*x))/b
| |
− | print('nilai x', x, 'nilai y', y)
| |
− |
| |
− | elif a!=p:
| |
− | s=(a*p)
| |
− | t=(b*p)
| |
− | u=(c*p)
| |
− | ss=(p*a)
| |
− | tt=(q*a)
| |
− | uu=(r*a)
| |
− | x=(u-uu)/(t-tt)
| |
− | y=(c-(a*x))/b
| |
− | print('nilai x=', x, 'nilai y=', y)
| |
− | input()
| |