Reporting error in quizz ! | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Reporting error in quizz !

Has somebody else noticed this error wirh this quizz question? def p(a,b): t1 = ++a t2 = -b return t1 * t2 print (p(3,2)) The answer is -6 (sorry for the spoiler :)), and it's always corrected 6. I've reported it a few times. It's not a detail as I, and probably other people, am always confused. Not really encouraging in the learning process... there's another one incorrect question hanging around. Just a small corner rounding :)

26th Nov 2017, 9:16 PM
Nec - avatar
8 ответов
+ 7
As @Kuba has stated, that there's no pre-increment/decrement operator in Python, I would say this is a deceiving quiz, given the use of unavailable operator in the language in question, I know quizzes are not supposed to be easy, but that is a foul trick. @ChaoticDawg was also correct when he said -- will do negation twice, I don't know why question with invalid operator play like that should pass the filtering process. Just my thoughts... :)
27th Nov 2017, 6:47 AM
+ 12
It actually is correct. From what I recall, the definition is: t1 = ++a t2 = --b # note the double minus Python does not support pre- and post-increment operators like C++ does. In Python ++a means a, just like --b equals -(-b). So, in both cases t1 and t2 equal to juzt a and b, respectively.
26th Nov 2017, 9:47 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
@cHampsonR, Very true, anyway, @Kuba & @ChaoticDawg had previously made that point clearly, the thing with this quiz code isn't about whether its code runs, but it is deceiving into "believing" that there is actually a post/pre increment operator in Python, despite of the need for an effort to solve it, is that really a way of education? I was wondering if the same trick can be used on other languages' quiz, to falsely lead the quiz solver to believe something actually exist, while they don't, just so it doesn't get solved too easily :)
27th Nov 2017, 11:55 PM
+ 4
The last time I saw that question, it was a double negation on b. Going by that, 6 is the correct answer
27th Nov 2017, 4:40 AM
Divesh Singh
Divesh Singh - avatar
+ 3
The answer is -6 @Kuba you're correct about there not being any ++ or -- operators, but -b will do a mathematical negation on b. it's the same as -1 * b which will make t2 = -2 so p will return 3 * -2 which equals -6. If there were 2 -- as you stated, then it would be 6, as b would be negated twice. This is probably just a typo in the question, but the correct answer is still -6 as it is.
26th Nov 2017, 10:11 PM
ChaoticDawg - avatar
+ 3
on the line which says -b, it's supposed to be --b, first off. Second, Python doesn't support post/pre increment, so ++a just makes it positive twice, keeping it the same, and --b is -(-b), keeping it positive as well. Since nothing is changed with the values, 3*2, 6, is returned.
27th Nov 2017, 10:55 PM
cHampsonR - avatar
+ 1
From your question the answer is actually -8. that is ++(3) which is 4 multiplied with negative two (-2)==-8!If the answer is incorrect there is an 100% chance it will never get approved
26th Nov 2017, 9:25 PM
᠌᠌Brains[Abidemi] - avatar
+ 1
before reporting CHECK it in Play Ground!
27th Nov 2017, 8:21 AM