ProgrammingHardGATE CS · Product-company placement
What is printed?
What is printed?
print(int("٤٢"), "²".isdigit(), "²".isdecimal(), "½".isnumeric(), "4.2".isdigit())- A. ValueError True True True False
- B. 42 False False True False
- C. 42 True False True False
- D. 42 True False False True
Correct answer: C. 42 True False True False
int() accepts any Unicode decimal digits, so Arabic-Indic digits parse as 42. Superscript 2 is a digit but not a decimal; ½ is numeric only; '4.2' contains a dot, so isdigit() is False.
More Python Programming questions
- What is printed? python a = 10 16 print(float(a + 1) == float(a), int(float(2 53 + 1)) - 2 53, 2 53 + 1.0 == 2 53)
- What is printed? python print(divmod(-17, 5), divmod(17, -5), -17 % -5, pow(3, -1, 7))
- What is printed? python print(not 1 == 2, not (1 == 2) is True, (not 1) == 2, 1 + True + True)
- What is printed? python x = 5 print(1 < x < 10 > 3 != 4, 3 > 2 > 1 == True, (3 > 2) > (1 == True), 0 == 0 in [0])
- What is printed? python s = "a,b,,c," print(len(s.split(",")), len(s.split()), s.rsplit(",", 2)[0], s.partition(";")[0] == s)
- What is printed? python s = "a btcn" print(s.split(), len(s.split(" ")), len(s.strip(" ")), len(s.strip()))