ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(0 ** 0, 0.0 ** 0, (-8) ** 0, (-2) ** 3, -2 ** 3)
- A. 1 1.0 1 -8 -8
- B. 1 1.0 0 -8 -8
- C. 0 1.0 1 -8 -8
- D. 1 1 1 -8 -8
Correct answer: A. 1 1.0 1 -8 -8
Any number to the power 0 is 1, and the float case stays a float: 0.0 ** 0 is 1.0. -2 ** 3 parses as -(2 ** 3), which is -8, the same as (-2) ** 3 here.
More Python Programming questions
- What is printed on the first line? python print(sorted(['10', '9', '2'], key=int)) print(sorted(['10', '9', '2'])) print(sorted(['a', 'B'…
- What is printed? python print('a' 'b' 2, ('a' 'b') 2, 'ab' 0 == '', 'x' 3 + 'y' 2)
- What is printed? python print('%.2f' % 2.675, '%.2f' % 2.665, round(2.665, 2), format(2.5, '.0f'), format(0.125, '.2f'))
- What is printed? python print(0.1 + 0.2 + 0.3 == 0.6, 0.3 + 0.2 + 0.1 == 0.6, 0.1 + (0.2 + 0.3) == 0.6)
- What is printed? python from decimal import Decimal print(Decimal('0.1') + Decimal('0.2') == Decimal('0.3'), Decimal(0.1) ==…
- What is printed? python from fractions import Fraction print(Fraction(1, 3) + Fraction(1, 6), Fraction(0.5), Fraction('0.1') +…