ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(oct(64), hex(-255), bin(0))
- A. 100 -0xff 0b0
- B. 0o64 -0xff 0b0
- C. 0o100 -0xff 0b0
- D. 0o100 0xfe 0b0
Correct answer: C. 0o100 -0xff 0b0
oct and hex add their prefixes. The 0o prefix shows 64 as 100 in base 8. A negative number keeps its minus sign in front of the prefix.
More Python Programming questions
- What is printed? python print(ord('A') ^ 32, chr(ord('a') - 32))
- What is printed? python t = ([],) t[0].append(1) print(t, t[0] is t[0])
- What is printed? python print(list(dict.fromkeys('mississippi')))
- What is printed? python print(any([]) or all([]) and 'x')
- What is printed? python s = 'hello' print(s[1:-1][::-1], s[-1:0:-2])
- What is printed? python d = {} d.setdefault('k', []).append(1) d.setdefault('k', []).append(2) print(d)