from math import sqrt def zad1(): delta=0 #("Podawaj odpowiednio wartosci a,b,c: ") a=int(input("Podaj a:")) b=int(input("Podaj b:")) c=int(input("Podaj c:")) if a==0 and b!=0: print("y=bx+c") return -c/b elif a!=0: print("y=ax^2+bx+c") delta=b**-4*a*c if delta<0: return "Brak rozwiazan" elif delta==0: return -b/(2*a) elif delta>0: delta=sqrt(delta) x1=(-b+delta)/(2*a) x2=(-b-delta)/(2*a) return x1, x2 elif a==0 and b==0: if c==0: return "Nieskonczenie wiele rozwiazan" else: return c def zad2(): #("Podawaj odpowiednio wartosci a1,b1,c1,a2,b2,c2: ") a1=int(input("Podaj a1:")) b1=int(input("Podaj b1:")) c1=int(input("Podaj c1:")) a2=int(input("Podaj a2:")) b2=int(input("Podaj b2:")) c2=int(input("Podaj c2")) W=a1*b2-a2*b1 Wx=c1*b2-c2*b1 Wy=a1*c2+a2*c1 if W==0 and Wx==0: return "Nieskonczenie wiele rozwiazan" elif W==0 and Wx!=0: return "Brak rozwiazan" elif W!=0: x=Wx/W y=Wy/W return x,y def main(): rozw=0 n=input("Podaj zadanie 1 lub 2: ") n=int(n) print(n) if n==1: rozw=zad1() print(rozw) elif n==2: rozw=zad2() print(rozw) else: print("BLAD - brak opcji!!") return 0 if __name__=="__main__": main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question