ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(5 // 0.5, 5 % 0.5)
- A. 11 0.0
- B. 9.0 0.0
- C. 10.0 0.0
- D. 10.0 0.5
Correct answer: C. 10.0 0.0
Mixing an int with a float makes the result a float, so both values print with a decimal point.
More Python Programming questions
- What is printed? python print('xy'.replace('', '-'))
- What does this Python code print? a = [1, 2, 3] b = a a += [4] a = a + [5] print(b, a)
- What does this Python code print? it = iter([1, 2, 3, 4, 5]) print(any(x > 2 for x in it), next(it))
- What does this Python code print? def f(x, acc=[]): acc.append(x) return len(acc) print(f(1), f(2), f(3, []), f(4))
- What is the output of this Python code? t = ([1], 5) try: t[0] += [2] except TypeError: print("err", end=" ") print(t)
- What does this Python code print? class A: items = [] n = 0 def add(self, x): self.items += [x] self.n += 1 a, b = A(), A() a.add(1)…