ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('{:+}'.format(-0.0), '{:+}'.format(0), '{:+.1f}'.format(-0.04), '{:+}'.format(5))- A. -0.0 +0 -0.0 +6
- B. -0.0 0 -0.0 +7
- C. -0.0 +0 -0.0 +5
- D. +0.0 +0 -0.0 +9
Correct answer: C. -0.0 +0 -0.0 +5
The + sign flag shows a sign for every number, and negative zero keeps its minus sign. The integer 0 gets a plus, and -0.04 rounds to -0.0 at one decimal.
More Python Programming questions
- What is printed? python print(hex(255).upper(), int('FF', 16) == 0xff, '%X' % 255 == hex(255)[2:].upper(), oct(64))
- What is printed? python print(0.1 + 0.2 != 0.3, 1 if 0.1 + 0.2 else 0, 0.0 or -0.0 or 'x', 0 and 1 or 2)
- What is printed? python print(len('u0301'), len('au0301'), 'au0301'.upper() == 'Au0301')
- What is printed? python words = 'the quick the lazy'.split() counts = {} for w in words: counts[w] = counts.get(w, 0) + 1 print(counts…
- What is printed? python print(sorted(['B', 'a', 'C'], key=str.casefold) == ['a', 'B', 'C'], sorted(['B', 'a', 'C']) == ['B', 'C', 'a']…
- What is printed? python print(int('1000') + int('01'), '1000'.replace('', '') == '1000', float('10.50'), '%.1f' % float('10.50'))