0

Hi! Did AI corrected me right?

#The task... Complete the code to create a tuple and display its 3rd item semaphore = ("Red", "Amber", "Green") # My answer... Can´t be that way in Tuples? print(semaphore[-1]) # Then AIs correction... The answer provided is not correct, as the last element of the tuple is being displayed instead of the third element. It should be: semaphore = ("Red", "Amber", "Green") print(semaphore[2])

20th Mar 2024, 12:52 PM
daniimad
daniimad - avatar
14 Réponses
0
daniimad , AI is stupid. It's your job to correct AI, not the other way around. That's what it means to "train" an AI, because human judgement is the final arbiter. In this case, the indexes are equivalent. semaphore = ("Red", "Amber", "Green") print(semaphore[-1]) # Green print(semaphore[2]) # Green
20th Mar 2024, 3:24 PM
Rain
Rain - avatar
+ 4
I don't recognize this question, maybe SL updated the course? By the way, if the tuple has 3 elements only and you want to print the last element, using index -1 is fine. However, if the tuple has more than 3 elements, index -1 prints the last element. Therefore, if you want it prints the 3rd element regardless of the tuple size, use index 2.
20th Mar 2024, 1:14 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 3
You can use indexing on the tuples, but not change their values ​​from the outside since the tuples are immutable, they stay at a fixed change, so the AI ​​did not make a mistake You can indicate in the normal way semaphore[-1] But changing the elements is not possible. semaphore.append("Blue") In which it would provide error
20th Mar 2024, 12:56 PM
STE4LPH
STE4LPH - avatar
+ 3
AI assumed that there might be more than 3 item in tuple (we see only 3 item) so if AI said print 3rd item then semaphore[2] is the right answer. Now you assume that there are 4 item so if you use index -1 then answer would be wrong because it will print 4th (last) item not 3rd item. That is what AI is saying. So AI is right here.
20th Mar 2024, 5:35 PM
A͢J
A͢J - avatar
+ 1
daniimad From what you have written... #The task... Complete the code to create a tuple and display its 3rd item As I see, print(seamphore[-1]) is not the correct answer. It is because the task didn't mention how large the tuple needed to be created. It can be one or two elements (which return IndexError if we want the third element since it doesn't exist), or a tuple with three or more elements. If you use index -1, it returns the last element, and it only work correctly if the tuple has 3 elements. To correctly access the third element on any tuple where the size is larger or equal to 3, index 2 is the correct answer. Thus, the AI is correct.
22nd Mar 2024, 2:18 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
daniimad I think the course is updated recently and made some changes to the exercise. I would be helpful if you post the entire task description and the given code if exists. However as I mentioned earlier, index -1 works only if the tuple has 3 elements, but index 2 works for every tuple as long as the size is bigger than 3. Therefore index 2 is a better answer.
22nd Mar 2024, 2:31 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Again... The tuple had 3 elements. I called the 3rd element using index -1. If it have had 4 elements, I wouldn't have used that Index... Nevermind... Xxx
22nd Mar 2024, 2:42 PM
daniimad
daniimad - avatar
0
Wong Hei Ming yes, I think these questions I cannot find in my completed courses means they updated the contents. I am currently going through them again one by one myself by resetting the course and retaking them again. I am setting a personal challenge to finish the course without running out of hearts. Some questions are tricky. Others are just ambiguous or inadequately explained. daniimad without more info on the task, it is hard to say if the AI is right or wrong . If the tuple is fixed at 3 items, [:-1] is the same as [2] and both points to the third item. But if the tuple length can be bigger, the correct answer is [2]
20th Mar 2024, 1:58 PM
Bob_Li
Bob_Li - avatar
0
Finally!! Thanks, Rain. Is exactly the same. That AI needs more training
20th Mar 2024, 3:51 PM
daniimad
daniimad - avatar
0
A͢J , Don't reify AI by suggesting it "assumed" something. It's not a mind. It doesn't think. It's an imitation algorithm. Given millions or hundreds of millions of text documents, it can find patterns in them and produce new text that imitates the patterns in the sources. It has no clue what words actually are, let alone what they mean. However, a person can find meaning in words and understand things. A person can even guess at what the writer was thinking. Some things I noticed as a human. 1. No other code was given by the OP, so let's assume the code is complete. If it isn't, that's on the OP. 2. The tuple type is immutable. You can't change its length. You can only reassign a new tuple to the same identifier (name). There's no reassignment in the given code. 3. Semaphore means signal. 4. The colors Red, Amber, and Green are the exact colors in the exact order of a traffic signal, top to bottom. 5. It's unlikely that a new color will be added to traffic signals anytime soon.
21st Mar 2024, 11:14 AM
Rain
Rain - avatar
0
Rain rules, good reply for A͢J
22nd Mar 2024, 1:33 PM
daniimad
daniimad - avatar
0
Wong Hei Ming The tuple was created. It has 3 elements, and it is immutable (a property of tuples)
22nd Mar 2024, 2:22 PM
daniimad
daniimad - avatar
0
daniimad -1 always called as last element even tuple ( or any other collection which can be access by index) have 2 elements or 3 elements or 4 elements doesn't matter. So you cannot use index -1 as 3rd element. AI is not stupid, it is humans mind to think -1 index as 3rd element (because of 3 element in tuple) even though it is not. If there is 'last element' in question then we should use index -1. Btw that was not good reply for me, that was useless. Note: AI is instructed by humans, so humans are stupid (indirectly). 😀😀😀
22nd Mar 2024, 5:46 PM
A͢J
A͢J - avatar