ProgrammingVery hardCodeforces-style · placement coding round
What is printed?
What is printed?
s = '\u00b2' print(s.isdigit(), s.isdecimal(), s.isnumeric())
- A. True False True
- B. False False True
- C. True True True
- D. True False False
Correct answer: A. True False True
The superscript two is a digit, so isdigit is True, but it is not a decimal digit, so isdecimal is False. isnumeric is True, and int() rejects the character.
More Python Programming questions
- What is printed? python d = {1: 'a'} d[1.0] = 'b' d[True] = 'c' print(d)
- What is printed? python def acc(): total = 0 while True: x = yield total if x is None: return total total += x g = acc() next(g) g.send(5)…
- What is printed? python class P: def init(self, x): self.x = x def eq(self, o): return self.x == o.x try: s = {P(1)} except TypeError…
- What is printed? python class S: slots = ('a',) s = S() s.a = 1 try: s.b = 2 except AttributeError: print('no dict', s.a)
- What is printed? python print(len(set(map(lambda x: x % 3, range(10)))), sum(1 for in filter(None, [0, 1, '', 'a', None])))
- What is printed? python def mpow(b, e, m): r = 1 b %= m while e: if e & 1: r = r b % m b = b b % m e >>= 1 return r print(mpow(2, 10…