Dobrý deň, pomohol by mi niekto napísať program, ktorý zistí, či zadaný bod leží na priamke danej rovnicou y= ax + b a vykreslí priamku a zadaný bod v Pythone.
Môj program vyzerá takto, vedel by ho niekto opraviť?
import math
y= float(input("Zadaj y: "))
a= float(input("Zadaj a: "))
x=float(input("Zadaj x: "))
b=float(input("Zadaj b: "))
if y == a*x + b:
print("Bod leží na priamke.")
else:
print("Bod neleží na priamke.")
import tkinter
canvas= tkinter. Canvas()
canvas.pack()
# Osi grafu
canvas.create_line(0, 250, 500, 250, fill="blue")
canvas.create_line(250, 0, 250, 500, fill="blue")
# Priamka
line_x1 = -250
line_x2 = 250
line_y1 = -a*line_x1 - b
line_y2 = -a*line_x2 - b
canvas.create_line(line_x1+250, line_y1+250, line_x2+250, line_y2+250, fill="red")
# Bod
canvas.create_oval(x+245, 245-y, x+255, 255-y, fill="black")
Are you looking for informatika tutoring? Find the right informatika tutor for online or in-person tutoring near you.
We access the information stored on your device for this website to function properly. This includes, for example, cookies or local browser cache. We use this to store the data necessary for the functioning of the website, data used for analytical purposes, or data stored by third parties.
If this information is essential for the operation of this website, we store it automatically. For everything else, we need your consent, which you can choose to give below. Your consent is valid for 12 months. Should you refuse, we will ask you for consent again in 6 months, but you are free to change your mind at any time. For more information, please see our GDPR and Terms of Use.