ProgrammingHardGATE CS · Product-company placement
What is printed?
What is printed?
print(int("12", 8), oct(64), hex(-255), int("z", 36), format(10, "b").zfill(6))- A. 10 0o100 -0xff 35 001010
- B. 12 0o100 -0xff 35 001010
- C. 10 0100 0x-ff 35 001010
- D. 10 0o100 -0xff 36 1010
Correct answer: A. 10 0o100 -0xff 35 001010
'12' in base 8 is 10. oct and hex use 0o and 0x prefixes with a leading minus for negatives. Base 36 uses 0-9 then a-z, so 'z' is 35. format(10, 'b') is '1010', zero-padded to 6.
More Python Programming questions
- What is printed? python x = 2 63 print(x.bitlength(), (x - 1).bitlength(), x >> 62, (-1) >> 100, 1 << 0, (5).tobytes(2, "big"))
- What is printed? python import math print(math.floor(-2.5), math.ceil(-2.5), math.trunc(-2.5), int(-2.5), round(-2.5), -2.5 // 1)
- What is printed? python print(3 "ab" == "ab" 3, [1] 3 is [1] 3, "%" in "100%", "100%%" % (), f"{{x}}")
- What is printed? python x = 10 s = f"{x=}, {x2=}, {x:04}, {'a' if x > 5 else 'b'}" print(s)
- What is printed? python def f(): yield 1 g = f() print(type(f).name, type(g).name, hasattr(g, "next"), iter(g) is g, callable(g))
- What is printed? python class Matrix: def init(self, r): self.r = r def getitem(self, idx): i, j = idx return self.r[i][j] def…