ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
from functools import partial
f = partial(int, base=2)
print(f('101'), f('11', base=10))- A. 5 11
- B. 5 3
- C. 101 11
- D. 5 10
Correct answer: A. 5 11
partial stores base=2 as a default keyword, and a keyword passed at call time overrides it. So f('101') is 5 and f('11', base=10) is 11.
More Python Programming questions
- What is printed? python print(list(zip([(1, 'a'), (2, 'b')])))
- What is printed? python print(1 if 0 else 2 if 1 else 3, (lambda: 1 if False else 'x')())
- What is printed? python print(type(1/1).name, type(1//1).name, type(2-1).name, type(21).name)
- What is printed? python print(sorted({x % 4 for x in range(10)}))
- What is printed? python print('xxhixx'.strip('x') + '|' + 'abc'.strip('ac'))
- What is printed? python print(len(str(2100)), str(2100)[:5])