-ENDED- Do something that looks like something else

Javascript

var а;
a = 1;
а++;
alert( a );

Answer: It outputs 1. The comments below explain it pretty well - there are two different variables here, a - 'LATIN SMALL LETTER A' and а - 'CYRILLIC SMALL LETTER A'.

There was 1 correct answer, 50 people thought it outputs 2, and with a total of 52 answers, the score is (50 - 1) / 52 = 49 / 52 = 94,23%


C, Score 33.3%

#include <stdio.h>
int main(int ac, char **av) {
        const char *arg = av[1];
        #define valid_ch(ch) (ch!='&' && ch!='\\')  // All valid except & and \
        while (*arg)
        {
                if (valid_ch(*arg)) putchar(*arg);
                arg++;
        }
        puts("");
        return 0;
}

Run ./prog 'Hello & goodbye, world!'

Score

The correct answer is H\n (the while is part of the comment, thanks to the line ending with \, so there's no loop), given by 6 people.
The most popular mistake was Hello goodbye, world\n, given by 25 people.
(25 - 6) / 57 = 33.3%.
Thanks to Olivier Dulac for bothering to calculate.


Python

a = []
for i in range(10):
    a.append(i * ++i)
for a[i] in a: 
    print(a[i])

Rating

  1. Good answer: Prints 0 1 4 9 16 25 36 49 64 64, each number on one line.

  2. Explanation: Despite nobody getting the right answer, I consider this mostly a failed attempt, because nobody made the mistake I had intended. (I'll add a real explanation later if nobody else does.)

  3. Number of good answers: 0

  4. Number of peoply with same wrong answer: 7

  5. Total number of answers: 11

  6. Score: 63,64 % (rounded to two decimals)

Explanation

First, a list a is created and filled with values i * ++i. There is no ++ operator in Python, but there is a unary + operator, which does nothing for integers, and applying it two times still does nothing. So a contains the squares of the integers from 0 to 9.

I had put the ++ as a distraction and hoped that most voters would go on, thinking they had found the trap, and fall into the real trap. It didn't work out. Some thought that ++ is a syntax error, and the others still looked for the trap.

The trap The trap was in the second for loop:

for a[i] in a: 
    print(a[i])

I was sure that most people would think this prints out all the a[i], i.e. 0 1 4 9 16 25 36 49 64 81, each number on one line. That's what you get with this variaton, for example:

for x in a: 
    print(x)

x is assigned the values in a, and then x is printed. In the first version, a[i] is assigned the values in a, and then a[i] is printed. The difference is, that in our case we have i == 9, and thus the value of a[9] is changed each time through the loop. When finally a[9] is printed, it has the value of a[8], and thus 64 is printed again.