ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(int(9.99), int(-9.99), round(9.99), round(-9.99), 0)
- A. 9 -10 10 -10 0
- B. 9 -9 10 -10 0
- C. 10 -9 10 -10 0
- D. 9 -9 9 -9 0
Correct answer: B. 9 -9 10 -10 0
int truncates toward zero, so 9.99 gives 9 and -9.99 gives -9. round to the nearest integer gives 10 and -10.
More Python Programming questions
- What is printed? python def span(p): st, out = [], [] for i, x in enumerate(p): while st and p[st[-1]] <= x: st.pop() out.append(i…
- What is printed? python def peak(a): lo, hi = 0, len(a) - 1 while lo < hi: mid = (lo + hi) // 2 if a[mid] < a[mid + 1]: lo = mid + 1 else…
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def f(e, n): if n == 0: return 0 if e == 1: return n lo, hi…
- What is printed? python def lal(a): dp = [dict() for in a] best = 0 for i in range(len(a)): for j in range(i): d = a[i] - a[j] dp[i][d] =…
- What is printed? python def pi(s): p = [0] len(s) k = 0 for i in range(1, len(s)): while k and s[i] != s[k]: k = p[k - 1] if s[i] == s[k]…
- What is printed? python from collections import deque def bip(g): col = {} for s in g: if s in col: continue col[s] = 0 q = deque([s])…