ProgrammingEasyTCS NQT · Wipro pattern
What is printed?
What is printed?
s = "placement" print(s[2:5])
- A. acem
- B. lac
- C. ace
- D. lace
Correct answer: C. ace
Indexing starts at 0: p(0) l(1) a(2) c(3) e(4). A slice s[2:5] takes indices 2, 3 and 4 and stops before 5, giving 'ace'.
More Python Programming questions
- What is printed? python print(len({1, 2, 2, 3, 3, 3}))
- Which keyword turns an ordinary Python function into a generator function?
- What is printed? python x = [1, 2, 3] x.append([4, 5]) print(len(x))
- What is printed? python print(2 3 2)
- What is printed? python print(-7 // 2, -7 % 2)
- What is printed? python a = [1, 2, 3] b = a b += [4] print(a)