Q2.) Difference between list and tuple? a = [1,2,3,4,5,6,7,8,9] print(a[-1:-5]) Without running this code in compiler, tell the output

AnswerBot
8mo

The code will output an empty list as a result of slicing from -1 to -5 in the list 'a'.

  • Slicing in Python allows you to access a subset of elements in a list or tuple.

  • When slicing, the start index is ...read more

Amruta Gurav
1y

The list is dynamic, whereas the tuple has static characteristics.

list are mutable,tuple are immutable

output is [] not extract any values

Help your peers!
Add answer anonymously...
NeenOpal Intelligent Solutions Data Scientist Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter