ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(type(1/1).__name__, type(1//1).__name__, type(2**-1).__name__, type(2**1).__name__)
- A. float float float int
- B. int int float int
- C. float int int int
- D. float int float int
Correct answer: D. float int float int
/ always gives a float and // keeps an int. A negative integer exponent gives a float, while a non-negative one stays an int.
More Python Programming questions
- 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])
- What is printed? python print(sorted([[2, 'b'], [1, 'z'], [2, 'a']]))
- What is printed? python x = [1, 2, 3] y = x.copy() y.append(4) print(len(x), len(y), x is y)
- What is printed? python print('aaa' < 'b', 'abc' > 'abd')