ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print([n for n in range(100, 1000) if sum(int(d) ** 3 for d in str(n)) == n])
- A. [153, 370, 371, 407]
- B. [153, 370, 371]
- C. [153, 407]
- D. [153, 370, 371, 401]
Correct answer: A. [153, 370, 371, 407]
These are the three-digit Armstrong numbers, where each digit cubed sums to the number itself. 407 is the fourth one, and the list is the complete set in this range.
More Python Programming questions
- What is printed? python print(bin(37).count('1'), bin(37)[2:].count('0'), (37).bitlength() - bin(37).count('1'))
- What is printed? python x, count = 0b1011011, 0 while x: x &= x - 1 count += 1 print(count, bin(0b1011011).count('1'))
- What is printed? python def isanagram(a, b): return sorted(a) == sorted(b) print(isanagram('listen', 'silent'), isanagram('abc', 'abcc')…
- What is printed? python print(pow(3, 1018, 7), pow(3, 6, 7), pow(3, 1018 % 6, 7))
- What is printed? python print(sum(range(10)) / len(range(10)), sum(range(10)) // len(range(10)), sum(range(1, 11)) % 7)
- What is printed? python n = 12345 print(n // 10 3 % 10, n % 10 3 // 100, str(n)[1], n // 1000 % 10 == int(str(n)[1]))