#๐ list problem
275 messages ยท Page 1 of 1 (latest)
@empty sail
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
homework assignment for python module in engineering course
so, have you learnt about list.pop?
i googled it just now
i understand that it will remove the last element
the code to check last element in list tho
yes, for that you would go about doing negative indexing
items[-1] refers to the last element in items
essentially:
[1, 2, 3, 4, 5]
index: 0 1 2 3 4
rev_index:-5 -4 -3 -2 -1
so now
so basically -1 is always the "last" because its counted from the right so its always the first
ok
you can use your knowledge of looping and think of the conditions you need to check
yep, its always last
there is one more condition, you are forgetting that the list should not be trimmed beyond the last element
;-; thanks
best of luck
oof, good luck
ill send it if ur curious
let it be a mystery
nvm u cant upload files
gg
part a from Q1 when it goes to like abcdefghi lmao
its not too bad
ooh you're building to spec
but im shit at python
just use a language you're comfortable then
idk any other language
they kinda just expect us to learn python alongside engineering which is valid but i always struggled with coding one day ill b good tho
its alright, they should've have included python in lectures
savages
well you'll be alright, you have this discord to ask questions to.
if someone wants to hop on vc for a sec i got a question about how to implement this into the code i got
coz we get a unit tests file that is specific
about waht it wants
its alr, you can post it here, this is ur thread
im not familiar with python's unit tests
but with docs available it won't be too bad
while list[-1] == 0 and len(list)>1:
TypeError: 'type' object is not subscriptable
gimme a sec tho might just be like
where is your list defined?
paste your entire code
yes, you need to replace list in the above for ur variables
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
yep
yea
ah okay
because List is part of yourself
ah yea
class is the blueprint
the object that you 3d print is an instance of that blueprint
right okay
yea making sense
well im stuck on the next part if ur not doing anything lol
its the coefficients and degrees
a moment, lemme see
and the unit tests i sent are the inputs
essentially, the List that you are storing is a list of cofficients for an equasion
Yes
instead of storing it into List
store it into self.cofficients
(sadly, you will have to rename a lot of stuff)
instead of self.List = List, you'd have to do self.cofficients = List and then replace everything that used List with cofficients
i see
you are renaming a property/attribute
yep
well yea thats self, List... ๐คฆโโ๏ธ
anyway
okay so what about my line of code down there, useless basically
yep, pretty much, you can safely discard it
ignore the # there for now ig is not relevant too
nice okay so how do i assign degrees
uh well
how is degrees defined?
i mean
do you go asscending
or descending?
because the order of cofficients should match the order of degrees
right?
how is the equation defined?
umm
hold on a sec
uhh
can u hop into vc ill screenshare?
u dont need a mic
its just kinda easier for me to explain and show u what i can see
you essentially can't screenshare in this server without a helper/mod being present in vc
its alr, just send screenshots
!paste
or use this
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
i can add u as a friend
sorry, its a personal policy, i don't take dm or fr
right
as you can see
the degrees of the polynomial is stored ascendingly
so your degrees of polynomials are essentially [0, 1, 2, 3, ..., n]
yep
you create an empty list and add numbers to it in ascending order until its filled with correct length
that polynomials start with 1x^0 instead of 1x^1
ah yea
the constant term is x^0
noop
not that way
you need to create an empty list
and then add items to it :)
using append
lists are made using [] square brackets instead
so like self.degree = [] and then
self.degree.append(self.coefficients)
-1 ?
or idk
no no
you need to loop, i'll write some examples for you to better understand it, 1 moment
alright thanks
when you define a list
my_list = []
you can append items to it one by one
my_list.append(5)
my_list.append(3)
print(my_list)
[5, 3]
so you can use the range function, which essentially is a counter
range(4) = [0, 1, 2, 3]
remember, range will never include the last item but will always start from 0
so when you combine this
my_list = []
for item in range(5):
my_list.append(item)
print(my_list)
[0, 1, 2, 3, 4]
now, use the above knowledge and substitute 5 with whatever number of cofficients you have to make the degrees
yep, that is len() of your self.cofficients
ah ok
len function returns the length of ur list
self.degrees = []
yepppp
perfect โจ
hot
seems to not work
am i forgetting that its - 1
or something
@leaden kiln
@leaden kiln pliz help
@empty sail Okay, so if you give me a minute, I can read through this thread, or you can give me a quick summary on what you currently need help with.
yeah i can try
basically
ok so i am making the degree part
ill show u code
these are the unit tests we get for our code
This appears to be graded work.
ok the self.degree.pop[0] is basically a random guess to see if it works i need the degree list to like
work
yea
Okay, in which case, the assistance I'm able to provide may be limited, which, given the subject matter, may not be at all noticeable in terms of difference.
okay
well what can u help me with basiccally i need the list of degrees to match the polynomial
So you're aware, asserts generally should only ever be included in unit testing code, not your code code. There's an option to turn off asserts in Python, which means if you're even relying on them for your program logic, someone could turn those off and someone's day.
well we have to include assertions in our own code too
so im thinking its basically the length of the list of coefficients minus 1
So long as you understand that may be considered as undesirable beyond this course.
yes i understand that
Is this a comparison testing operation you're wanting to make?
this is how the coefficients should be defined
im just trying how to figure out how to extrapolate self.degrees
from self.coefficients
as you can see they define it in the tests
What is a degree?
its just - 1
I understand degrees as in 360 degrees, but...
Or as in ouch, that is rather hot, isn't it?
;-;
Or the third degree.
Degree of a polynomial ?
Yes.
that...
I'm not mathy.
ok anyway
so bascially i can see this
so from this u can kinda decipher that the degree is the polynomial with the front 0's removed minus 1
I'm just looking at that for loop in your polynomial class.
It doesn't appear to be especially useful.
its also not relevant to what im asking i understand your concern but
it is useful
the inputs are not limited to what i have shown, you can get non float/intergr inputs
So I'm seeing this. https://en.wikipedia.org/wiki/Degree_of_a_polynomial
In mathematics, the degree of a polynomial is the highest of the degrees of the polynomial's monomials (individual terms) with non-zero coefficients. The degree of a term is the sum of the exponents of the variables that appear in it, and thus is a non-negative integer. For a univariate polynomial, the degree of the polynomial is simply the high...
I'm sorry, I don't know how to assist you with this without an education in the subject matter.
Good.
in future say that at first haha the first guy that helped me was a genius ;-;
this isnt everyones cup of tea its engineering mathmatics python
I did say I wasn't mathy.
not fun
You also said this was a list problem.
Seriously? That's all?
no maths involved really just reverse engineered the unit tests
yesman
u probs overcomplicated it
although i dont blame u
i have been stressing this the last 3021312321 horus
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ list problem