38 תשובות
שואל השאלה:
אשמח אם מישהו יוכל להגיד לי מה אני צריך להוסיף ואיפה, תודה לעוזרים!
אשמח אם מישהו יוכל להגיד לי מה אני צריך להוסיף ואיפה, תודה לעוזרים!
מה השגיאה שזה זורק?
שואל השאלה:
nameerror: name 'point' is not defined
nameerror: name 'point' is not defined
שואל השאלה:
אם הבנתי נכון חסר לי קוד לפוינט, איך עושים אתזה?
אם הבנתי נכון חסר לי קוד לפוינט, איך עושים אתזה?
כנראה לא עשית import לספרייה שבה יש את הpoint
מאיפה הפייתון יידע למה אתה מתכוון?
מאיפה הפייתון יידע למה אתה מתכוון?
שואל השאלה:
ניסיתי לעשות import ועדיין יש לי שגיאה, מישהו מכם יכול בבקשה לכתוב לי מה בדיוק השורה שאני צריך לכתוב? אני לא טוב ככ בזה..
ניסיתי לעשות import ועדיין יש לי שגיאה, מישהו מכם יכול בבקשה לכתוב לי מה בדיוק השורה שאני צריך לכתוב? אני לא טוב ככ בזה..
שואל השאלה:
?
?
שואל השאלה:
אני בסעיף 2:
1. create, in a separate file, 5 different objects of rectangle and 5 different objects
of triangles. determine their values using loops / incremental variables / random
variables. do not create the objects in 10 copy-paste lines.
2. use your abilities with sorting and searching and write the function sort_objects,
which gets as input the list from (1). at the end of your algorithms, the list will be
sorted from the smallest area to the biggest. this algorithm should be
implemented twice: first, in a bubble sort, and second with a selection sort.
אני בסעיף 2:
1. create, in a separate file, 5 different objects of rectangle and 5 different objects
of triangles. determine their values using loops / incremental variables / random
variables. do not create the objects in 10 copy-paste lines.
2. use your abilities with sorting and searching and write the function sort_objects,
which gets as input the list from (1). at the end of your algorithms, the list will be
sorted from the smallest area to the biggest. this algorithm should be
implemented twice: first, in a bubble sort, and second with a selection sort.
תיצור class של point
שואל השאלה:
point כבר מוגדר אצלי לכן אני לא מצליח להבין למה זה לא רץ.
class point:
def _init_(self,x,y):
self.x=x
self.y=y
def _str_(self):
return "("+str(self.x)+","+str(self.y)+")"
point כבר מוגדר אצלי לכן אני לא מצליח להבין למה זה לא רץ.
class point:
def _init_(self,x,y):
self.x=x
self.y=y
def _str_(self):
return "("+str(self.x)+","+str(self.y)+")"
שים לב לאות גדולה בשם של point.
השתמשת באות קטנה בשאר הקוד
השתמשת באות קטנה בשאר הקוד
שואל השאלה:
ניסיתי, ועכשיו השגיאה שיוצאת :point() takes no arguments
ניסיתי, ועכשיו השגיאה שיוצאת :point() takes no arguments
כתבת __init__ נכון?
שואל השאלה:
ואו כן שיניתי עכשיו ל __init__ עכשיו מקבל שגיאה חלקית.. מקבל:'int' object is not iterable
ועברתי על הכל לא מבין עכשיו איפה הטעות
ואו כן שיניתי עכשיו ל __init__ עכשיו מקבל שגיאה חלקית.. מקבל:'int' object is not iterable
ועברתי על הכל לא מבין עכשיו איפה הטעות
שואל השאלה:
מציין הוספתי גם numberofloops = 5 כדי לבדוק אם זה עובד..
מציין הוספתי גם numberofloops = 5 כדי לבדוק אם זה עובד..
אי אפשר לעשות את זה ככה בפייתון.
צריך for i in range(number_of_loops):
הin range חשוב
צריך for i in range(number_of_loops):
הin range חשוב
שואל השאלה:
תודה רבה לך על העזרה, אני מקבל שגיאה של: name 'number_of_loops' is not defined
איך אני מגדיר את הנאמבר אוף לופס? מה אני אמור לכתוב לפני ?
תודה רבה לך על העזרה, אני מקבל שגיאה של: name 'number_of_loops' is not defined
איך אני מגדיר את הנאמבר אוף לופס? מה אני אמור לכתוב לפני ?
התכוונתי למשתנה שלך numberofloops.
תעשה שהוא שווה למשל ל5.
כתבתי את זה ככה כי זו המוסכמה בפייתון לשמות של משתנים אבל זה לא ממש קריטי
תעשה שהוא שווה למשל ל5.
כתבתי את זה ככה כי זו המוסכמה בפייתון לשמות של משתנים אבל זה לא ממש קריטי
שואל השאלה:
הכל נראה תקין... לא ברור לי עדיין מה לא בסדר בזה:
numberofloops=5
rectanglelist = []
triangleslist = []
import random
for i in range(5):
lengthrandomnumber = 20*random.random()
widthrandomnumber = 15*random.random()
newpoint = point(25*random.random(), 25*random.random())
newrectangle =rectangle(lengthrandomnumber,widthrandomnumber, newpoint.x, newpoint.y)
rectanglelist.append(newrectangle)
for i in range(number_of_loops):
firstpoint = point(25*random.random(), 25*random.random())
secondpoint =point(25*random.random(), 25*random.random())
thirdpoint = point(25*random.random(), 25*random.random())
newtriangles = triangles(firstpoint.x, firstpoint.y, secondpoint.x, secondpoint.y, thirdpoint.x, thirdpoint.y)
triangleslist.append(newtriangles)
הכל נראה תקין... לא ברור לי עדיין מה לא בסדר בזה:
numberofloops=5
rectanglelist = []
triangleslist = []
import random
for i in range(5):
lengthrandomnumber = 20*random.random()
widthrandomnumber = 15*random.random()
newpoint = point(25*random.random(), 25*random.random())
newrectangle =rectangle(lengthrandomnumber,widthrandomnumber, newpoint.x, newpoint.y)
rectanglelist.append(newrectangle)
for i in range(number_of_loops):
firstpoint = point(25*random.random(), 25*random.random())
secondpoint =point(25*random.random(), 25*random.random())
thirdpoint = point(25*random.random(), 25*random.random())
newtriangles = triangles(firstpoint.x, firstpoint.y, secondpoint.x, secondpoint.y, thirdpoint.x, thirdpoint.y)
triangleslist.append(newtriangles)
מה הerror?
שואל השאלה:
nameerror: name 'triangles' is not defined...
לא מבין למה.. הtriangle כן מוגדר..
ניסיתי גם לשנות לבלי הs וזה עדיין נותן אותה שגיאה...
מה שהגדרתי קודם לכן:
class triangle :
def __init__(self,x,y,x1,y1,x2,y2):
self.x=x
self.y=y
self.x1=x1
self.y1=y1
self.x2=x2
self.y2=y2
print("its ok")
nameerror: name 'triangles' is not defined...
לא מבין למה.. הtriangle כן מוגדר..
ניסיתי גם לשנות לבלי הs וזה עדיין נותן אותה שגיאה...
מה שהגדרתי קודם לכן:
class triangle :
def __init__(self,x,y,x1,y1,x2,y2):
self.x=x
self.y=y
self.x1=x1
self.y1=y1
self.x2=x2
self.y2=y2
print("its ok")
שינית לבלי הs בכל המקומות שזה מופיע בקוד?
שואל השאלה:
כן, וברגע ששינתי קיבלתי את זה :nameerror: name 'point' is not defined
מיואש כבר :,(
כן, וברגע ששינתי קיבלתי את זה :nameerror: name 'point' is not defined
מיואש כבר :,(
אם אתה מתקן משהו וזה עושה טעות חדשה זה לרוב אומר שהטעות הקודמת נפתרה ופשוט היו כמה טעויות מראש, אתה מתקדם
תשלח את הקוד של המחלקה point
שואל השאלה:
תודה על העזרה, הנה הקוד:
class point:
def __init__(self,x,y):
self.x=x
self.y=y
def _str_(self):
return "("+str(self.x)+","+str(self.y)+")"
תודה על העזרה, הנה הקוד:
class point:
def __init__(self,x,y):
self.x=x
self.y=y
def _str_(self):
return "("+str(self.x)+","+str(self.y)+")"
זו ההערה שזה נותן? אתה יכול לשלוח בהודעה אחת את כל הקוד?
שואל השאלה:
זה כל הקוד שכולל בתוכו את הpoint:
class point:
def __init__(self,x,y):
self.x=x
self.y=y
def _str_(self):
return "("+str(self.x)+","+str(self.y)+")"
class rectangle:
def __init__(self,width,height,x,y):
self.width=width
self.height=height
self.startpoint= point(x,y)
print("its work")
def _str_(self):
return str(self.width)+","+str(self.height)+","+str(self.startpoint.x)+","+str(self.startpoint.y)
def get_area(self):
return (self.width*self.height)
def get_diag_length(self):
power_width=(self.width)**2
power_height=(self.height)**2
return (power_width+power_height)**0.5
def get_border_points(self):
start_point= "("+str(self.startpoint.x)+","+str(self.startpoint.y)+")"
top_right_point="("+str(self.startpoint.x+self.width)+","+str(self.startpoint.y)+")"
bottom_right_point="("+str(self.startpoint.x+self.width)+","+str(self.startpoint.y-self.height)+")"
bottom_left_point="("+str(self.startpoint.x)+","+str(self.startpoint.y-self.height)+")"
return "the points of rectangle are:"+start_point+","+top_right_point+","+bottom_right_point+","+bottom_left_point
def add_value_height(self,value):
self.height+=value
def add_value_width(self,value):
self.width+=value
זה כל הקוד שכולל בתוכו את הpoint:
class point:
def __init__(self,x,y):
self.x=x
self.y=y
def _str_(self):
return "("+str(self.x)+","+str(self.y)+")"
class rectangle:
def __init__(self,width,height,x,y):
self.width=width
self.height=height
self.startpoint= point(x,y)
print("its work")
def _str_(self):
return str(self.width)+","+str(self.height)+","+str(self.startpoint.x)+","+str(self.startpoint.y)
def get_area(self):
return (self.width*self.height)
def get_diag_length(self):
power_width=(self.width)**2
power_height=(self.height)**2
return (power_width+power_height)**0.5
def get_border_points(self):
start_point= "("+str(self.startpoint.x)+","+str(self.startpoint.y)+")"
top_right_point="("+str(self.startpoint.x+self.width)+","+str(self.startpoint.y)+")"
bottom_right_point="("+str(self.startpoint.x+self.width)+","+str(self.startpoint.y-self.height)+")"
bottom_left_point="("+str(self.startpoint.x)+","+str(self.startpoint.y-self.height)+")"
return "the points of rectangle are:"+start_point+","+top_right_point+","+bottom_right_point+","+bottom_left_point
def add_value_height(self,value):
self.height+=value
def add_value_width(self,value):
self.width+=value
שואל השאלה:
וזה הקוד שלא עובד לי ..:
number_ofloops=5
rectanglelist = []
triangleslist = []
import random
for i in range(5):
lengthrandomnumber = 20*random.random()
widthrandomnumber = 15*random.random()
newpoint = point(25*random.random(), 25*random.random())
newrectangle =rectangle(lengthrandomnumber,widthrandomnumber, newpoint.x, newpoint.y)
rectanglelist.append(newrectangle)
for i in range(number_of_loops):
firstpoint = point(25*random.random(), 25*random.random())
secondpoint =point(25*random.random(), 25*random.random())
thirdpoint = point(25*random.random(), 25*random.random())
newtriangle = triangle(firstpoint.x, firstpoint.y, secondpoint.x, secondpoint.y, thirdpoint.x, thirdpoint.y)
triangleslist.append(newtriangle)
השגיאה:nameerror: name 'point' is not defined
וזה הקוד שלא עובד לי ..:
number_ofloops=5
rectanglelist = []
triangleslist = []
import random
for i in range(5):
lengthrandomnumber = 20*random.random()
widthrandomnumber = 15*random.random()
newpoint = point(25*random.random(), 25*random.random())
newrectangle =rectangle(lengthrandomnumber,widthrandomnumber, newpoint.x, newpoint.y)
rectanglelist.append(newrectangle)
for i in range(number_of_loops):
firstpoint = point(25*random.random(), 25*random.random())
secondpoint =point(25*random.random(), 25*random.random())
thirdpoint = point(25*random.random(), 25*random.random())
newtriangle = triangle(firstpoint.x, firstpoint.y, secondpoint.x, secondpoint.y, thirdpoint.x, thirdpoint.y)
triangleslist.append(newtriangle)
השגיאה:nameerror: name 'point' is not defined
השורה שזה אומר לך שיש בה טעות היא הפעם הראשונה שהשתמשת בpoint?
תבדוק אם הגדרת את המחלקה לפני שהשתמשת בה
תבדוק אם הגדרת את המחלקה לפני שהשתמשת בה
שואל השאלה:
זו השורה שיש בה טעות:
newpoint = point(25*random.random(), 25*random.random())
זו השורה שיש בה טעות:
newpoint = point(25*random.random(), 25*random.random())
הגדרת את המחלקה point לפני השורה הזו?
שואל השאלה:
אני צריך להגדיר אותה שוב? למרות שכבר הגדרתי קודם ?
אני צריך להגדיר אותה שוב? למרות שכבר הגדרתי קודם ?
לא. אולי זה לא עובד בגלל שהגדרת את המחלקה רק אחרי שהשתמשת בה
שואל השאלה:
הגדרתי אותה לפני.. זה היה סעיף קודם לכן
בכל אופן ניסיתי להגדיר מחדש וזה עדיין לא עובד :(
הגדרתי אותה לפני.. זה היה סעיף קודם לכן
בכל אופן ניסיתי להגדיר מחדש וזה עדיין לא עובד :(
תשלח לי בפרטי את הקוד כקובץ במייל או משהו
שואל השאלה:
ניסיתי לשלוח לך בפרטי אבל לא מצליח.. צריך פרחים משהו כזה(?)
ניסיתי לשלוח לך בפרטי אבל לא מצליח.. צריך פרחים משהו כזה(?)
שואל השאלה:
מוסיף פה קישור לקודים:
https://del.dog/polyfiburf.txt
או זה:
https://del.dog/raw/polyfiburf
מוסיף פה קישור לקודים:
https://del.dog/polyfiburf.txt
או זה:
https://del.dog/raw/polyfiburf
באותו הנושא: